Skip to content

Latest commit

 

History

History
17 lines (9 loc) · 348 Bytes

insertionSort.md

File metadata and controls

17 lines (9 loc) · 348 Bytes

Algorithm

step 1: Start

step 2: set i = 0

step 3: if i<n continue to step 4 else go to step 8

step 4: Set j = i-1 and current = arr[i]

step 5: if arr[j] > current and j >=0 continue to step 6 else go to step 7

step 6: a[j+1]=a[j] and set j = j-1 and go to step 5

step 7: Set a[j+1]= current and go to step 3

step 8: Stop