I need to know which sorting algorithm sorts like this:
[4 1 7 6 3 11]
[4 1 7 3 6 11]
[4 1 3 7 6 11]
[1 4 3 7 6 11]
[1 4 3 6 7 11]
[1 3 4 6 7 11]
Tomorrow is exam, and I'm confused. It shall be a simple algorithm, but it can't be insertion sort / selection sort, i even looked at heapsort (absolutely) and merge sort - last option.
I would say it's mergesort, but with the addition it should be easy, I'm unsure. Or i heavily misunderstood how the algorithms work. :(
Thanks for reading, at least! :)
As you can see, the algorithm works by comparing two adjacent values, which makes it a Bubble Sort, however the interesting thing to note here is that instead of the sorting being done in left to right passes, it seems to be doing them in passes from right to left; which in turn makes this a Reversed Bubble Sort.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With