What is the best case running time for insertion sort?
Answers
Answered by
0
In this case insertion sort has a linear running time (i.e., O(n)). During each iteration, the first remaining element of the input is only compared with the right-most element of the sorted subsection of the array. The simplestworst case input is an array sorted inreverse order.
Answered by
0
Answer:
Insertion sort runs in O ( n ) O(n) O(n) time in its best case and runs in O ( n 2 ) O(n^2) O(n2) in its worst and average cases. Best Case Analysis: Insertion sort performs two operations: it scans through the list, comparing each pair of elements, and it swaps elements if they are out of order.
Similar questions
World Languages,
8 months ago
Math,
1 year ago