Unverified Commit 78cb4256 authored by Lokesh Singh's avatar Lokesh Singh Committed by GitHub

Create bubble sort

parent a639c633
void swap(int *xp, int *yp)
{
int temp = *xp;
*xp = *yp;
*yp = temp;
}
void bubbleSort(int arr[], int n)
{
// Your code here
for(int i = 0; i<n-1; i++)
{
for(int j = 0; j<n-i-1; j++)
{
if(arr[j]>arr[j+1])
{
swap(&arr[j], &arr[j+1]);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment