Skip to main content

Bubble Sort Algo...


void bubbleSort(int arr[],int n) { int i,j,temp; for(i=0;i<n-1;i++) //last i elements are already in place { for(j=0;j<n-i-1;j++) { if(arr[j]>arr[j+1]) { //swaping arr[j] with arr[j+1] temp=arr[min_index]; arr[min_index]=arr[i]; arr[i]=temp; } } } }

Complexity of BubbleSort:
Time: O(n2)
Space: O(1)

Quote:

One day you will wake up and there won't be any more time to do the things you've always wanted. SO DO IT NOW...