What are the correct intermediate steps of the following data set when it is being sorted with the bubble sort (15, 20, 10, 18)?

Bubble sorts are the simplest sorting algorithm. in this algorithm we are sorting the data set if the data set in wrong order.

firstly we are comparing first two element if the first element is less than the second element so we will not swap these element.

we have the given element i.e (15,20,10,18) comparing first two element.

15 is less than 20 (not swap them)

(15,20,10,18) now we are comparing next element,

20 is grater than 10 ( swap both element)

(15,10,20,18) now we are comparing next two element,

20 is greater than 18 (swap both element)

(15,10,18,20) now we are starting from the beginning.

(15,10,18,20)

15 is greater than 10(swap both element)

(10,15,18,20)

15 is also less than 18(no swap)

(10,15,18,20)

18 is also than 20( so do not swap them)

now the sorted element is (10,15,18,20)

Comments

Popular posts from this blog

proassignment help backlink data index 41

programming shark backink data index 31

Programming shark backlink data index 67