Description:
Bubble
sort is the simplest and oldest sorting technique. This method takes two
elements at a time. It compare these two elements. If first elements is less
than second one, they are left undistrurbed. If the first element is greater
then second one then they are swapped. The procedure continues with the next
two elements goes and ends when all the elements are sorted.But bubble sort is an
inefficient
algorithm. The order of bubble
sort algorithm is O(n2).
Input/Output:
enter the range of array:3
enter elements into array:3 2 1
the sorted order is:1 2 3
enter the range of array:5
enter elements into array:56 23 34 12 8
the sorted order is: 8 12 23 34 56
VIVA QUESTIONS
1) Define bubble sort ?
Ans: : Bubble sort is the simplest and oldest sorting technique. This method takes two elements at a time. It compare these two elements. If first elements is less than second one, they are left undistrurbed. If the first element is greater then second one then they are swapped. The procedure continues with the next two elements goes and ends when all the elements are sorted.
2) display the efficiency of bubble sort ?
Ans : O(n2)
No comments:
Post a Comment