How recursive bubble sort work
Recursive Bubble Sort Base Case: If array size is 1, return. Do One Pass of normal Bubble Sort. This pass fixes last element of current subarray. Recur for all elements except last of current subarray. Example: Index= 0 1 2 3 4 5 6 7 100 90 80 70 60 50 40 30 Array []= Suppose we want to sort the above in the increasing order by the recursive bubble sort. Make a get grater which will return the grater of the array. Compare the first and last element of the array if the first is greater than last the swap with each other. And again call the sort function and decrement the array size by 1; 1) 30 90 80 70 60 50 40 100 ...
Comments
Post a Comment
if you have any confusion then ask hear.