What is the {average|worst}-case time for Insertion Sort to sort an array of n records?

\Theta(n^2)
  • \Theta(n)
  • \Theta(\log n)
  • \Theta(n \log n)

In the worst case, each record must make its way to the start of the array. This would occur if the record values are initially arranged from highest to lowest, in the reverse of sorted order.

In this case, the number of comparisons will be one the first time through the for loop, two the second time, and so on.