Searching
Finding an element in a collection, and the cost difference sorting buys you.
Pages in this Section
- Binary Search — Binary search finds a target in a sorted sequence by repeatedly halving the search range. O(log n) — the canonical "divide-and-conquer" example, and the basis for bisect in Python's standard library.
- Linear Search — Linear search walks an unsorted sequence one element at a time, returning the first match. O(n) — the only option when the data is unsorted or a tree/hash isn't available.
‹ Algorithms