In: Computer Science
Give a worst-case input sequence of 6 numbers for Insertion Sort, containing the numbers
68, 12, 43, 13, 58, and 21.
No explanation/proof required.
The answer for the above mentioned question is explained below ::
Worst case input sequence depends on the , style of implementation of the insertion sort algorithm .
While inserting new element into the array if we check the array position for the new element from the left side of the already sorted part of the array then the worst input sequence is
12,13,21,43,58,68
In the implementation of insertion sort algorithm , while inserting the new element if we check the array position for the new element from the already sorted part of the array from right side , then the worst case input sequence is 68,58,43,21,13,12