Imagine you have to sort a list of student records based on their roll numbers, where the records are already partially sorted. Which sorting algorithm would you choose, and why?

  • Bubble Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort
Insertion Sort would be suitable for this scenario. Since the records are already partially sorted, Insertion Sort's efficiency in dealing with nearly sorted data makes it a good choice. It has a linear time complexity for nearly sorted data, making it efficient in situations where the input is already somewhat ordered.
Add your answer
Loading...

Leave a comment

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