Explain what is ideal Sorting algorithm?

Technology CommunityCategory: SortingExplain what is ideal Sorting algorithm?
VietMX Staff asked 4 years ago

The Ideal Sorting Algorithm would have the following properties:

  • Stable: Equal keys aren’t reordered.
  • Operates in place: requiring O(1) extra space.
  • Worst-case O(n log n) key comparisons.
  • Worst-case O(n) swaps.
  • Adaptive: Speeds up to O(n) when data is nearly sorted or when there are few unique keys.

There is no algorithm that has all of these properties, and so the choice of sorting algorithm depends on the application.