Skip to article content
Interactive Notes

Algorithms Visualized

Array Search

Finding a value, or the k-th smallest, in an array

A linear scan checks every element in O(n)O(n) time, while binary search uses a sorted array to halve the search space each step, finding a value in O(log⁡n)O(\log n). Quickselect borrows quicksort’s partitioning to find the kk-th smallest element in expected O(n)O(n) time without sorting the whole array.