Bubble Sort is a simple sorting algorithms that iterates through a list and compares adjacent item and swaps them in the order if they are in the wrong order. The iteration is completed after the items bubble to there specific position and the list is sorted ascending or descending.
Bubble sort is simple but too slow and impractical in most of the cases.
Figure :
Algorithm:
CODE :
Bubble sort is simple but too slow and impractical in most of the cases.
Figure :
Algorithm:
for all elements in Array if Array[i] > Array[i+1] swap(Array[i], Array[i+1]) end if end for return Array
CODE :
Comments
Post a Comment