Quidest?

insertion sort algorithm

· Lorenzo Drumond

Insertion sort builds a final sorted list one item at a time. It’s much less efficient on large lists than more advanced algorithms like quicksort or merge sort.

Pseudocode

It has O(n^2) in worst case scenario, O(n) in best case.

Why use insertion sort

Some production sorting implementations use insertion sort for very small inputs under a certain threshold (very small, like 10-ish). Insertion sort is better for very small lists than some of the faster algorithms because:

References

Next -> quicksort-algorithm

#big_o #programming #computer_science #notation #algorithm #binary_search #sorting #boot_dev