Imagine you are working on a system where stability is crucial, and you need to sort a list of objects with identical keys. Which sorting algorithm would you choose, and why?

  • Heap Sort
  • Merge Sort
  • Quick Sort
  • Radix Sort
Merge Sort would be the preferred choice in this scenario. It is a stable sorting algorithm, meaning it preserves the relative order of elements with equal keys. Additionally, its time complexity of O(n log n) ensures efficient sorting, making it suitable for stable sorting tasks.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *