Array sorted in reverse order - Selection sort or Insertion sort?
  • basicsorting
  • sorting
  • selectionsort
  • insertionsort
  • sortedarray
  • array
  •   
  • Posted: 5 years ago
  • Updated: 4 years ago
  • Edit
  • answers (1)
  • views (6085)

Suppose you are given an array sorted in reverse order. Which sorting algorithm (running faster) will you choose to sort the array - Selection sort or Insertion sort?


Posted Answers

Both Selection sort and Insertion sort takes the same time for an array sorted in reverse order. Since the array is in reverse order, insertion sort will take \( O(n^2) \) time - it's worst case time complexity. Selection sort will also take \( O(n^2) \) time irrespective of reverse order or sorted order array.

You need to Sign In to post your solution.