Saturday, August 13, 2011

Worst Case Input For Sorting Algoritms?

The worst case input is an array sorted in reverse order. In this case every iteration of the inner loop will scan and shift the entire sorted subsection of the array before inserting the next element. For this case insertion sort has a quadratic running time (i.e., O(n2))

No comments:

Post a Comment