Consider a scenario where you have to sort a large dataset of positive integers ranging from 1 to 1000. Which sorting algorithm would be most efficient in terms of time complexity, radix sort, or merge sort? Justify your answer.

  • Insertion Sort
  • Merge Sort
  • Quick Sort
  • Radix Sort
Radix sort would be more efficient for sorting positive integers within a limited range like 1 to 1000. Its time complexity is O(nk), where 'n' is the number of elements, and 'k' is the number of digits in the largest number. In this scenario, the range is small, leading to a more favorable time complexity than merge sort.
Add your answer
Loading...

Leave a comment

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