Apples > Oranges?

Consider any given comparison sort. What is the least number of comparisons in the worst case it has to do in order to sort 5 numbers?


The answer is 7.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

展豪 張
Mar 6, 2016

Example:
Quick sort:
4 5 3 1 2
Compare [4] times (45, 43, 41, 42):
3 1 2 [4] [5]
Compare [2] times (31, 32):
1 2 [3] [4] [5]
Compare [1] time (12):
[1] [2] [3] [4] [5]
Total = 4+2+1 = 7


0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...