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?
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. |