Skip to content
Snippets Groups Projects
Unverified Commit 78cb4256 authored by Lokesh Singh's avatar Lokesh Singh Committed by GitHub
Browse files

Create bubble sort

parent a639c633
Branches
No related merge requests found
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]);
}
}
}
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