Please enable JavaScript.
Coggle requires JavaScript to display documents.
M1: Brute Force and Exhaustive Search, DECREASE AND CONQUER, First Step,…
-
DECREASE AND CONQUER
INSERTION SORT
All we need is to find an
appropriate position for A[n − 1] among the sorted elements and insert it there
By scanning the sorted subarray from right to left until the first element smaller than or equal to A[n-1] is encountered to insert A[n-1] right after that element.
-
Unlike selection sort, the number inserted are generally not in their final positions
First Step
-
Second Step
Scan the list one more time, starting with the second element, to find the smallest among the last n-1 elements in its final position.
scanning the entire given list to find its smallest element and exchange it with the first element, putting the smallest element in its final position in the sorted list.
-
-
-