Link Search Close Search Menu Expand Document

Insertion Sort

Insertion Sort works similar to the way playing cards are sorted.
It virtually partitions the array into sorted and unsorted set.
At each iteration, it takes one element from unsorted partition and places it in the right location within sorted partition.
This operation is repeated until no element is left in unsorted partition.
It has best case complexity of O(n), average and worst case complexity of O($n^2$).

Visualization of Insertion Sort

Implementation of Insertion Sort





Back to top

Copyright © 2020-2021 Gajanan Bhat. All rights reserved.