← Sorting

Pattern Recognition Drill

#29 — Insertion sort

Easy Sorting

The Problem

Sort an array using insertion sort.

What approach would you use?

Think about it before scrolling down.

Key Signals

Sorting

For each element, shift larger elements right and insert. O(n²) worst case, O(n) best (nearly sorted).

Common Trap

This is an algorithm implementation drill, not a problem-solving drill. Know the invariant: left portion is always sorted.

← #28 #30 →