Thursday, June 4, 2020

Insertion sort : explained

Steps on how it works:

  1. If it is the first element, it is already sorted.
  2. Pick the next element
  3. Compare with all the elements in sorted sub-list.
  4. Shift all the the elements in sorted sub-list that is greater than the value to be sorted to the right side.
  5. Insert the value.
  6. Repeat until list is sorted.