Binary Insertion Sort
Use binary search inside the sorted prefix to locate an insertion point before shifting values into place.
Core idea
Binary search locates the stable insertion boundary inside the sorted prefix. The array then shifts the suffix of that prefix and places the key at the boundary.
Read the visualization
First watch the half-open search interval shrink around the insertion point. The second phase highlights every value moved right before the key enters the gap.
Take the next key and search for its position inside the sorted prefix.
Complexity and tradeoffs
Time: O(n log n) comparisons; O(n^2) moves. Space: O(1). Binary search reduces comparisons, but contiguous insertion still requires shifting the suffix.
Where it fits
This variant helps when comparisons are costly, but it cannot avoid the quadratic number of array moves. Linked storage changes the move cost but loses direct midpoint access.