Searching Algorithms
Linear search checks everything; binary search halves the problem each step. Knowing when the second is possible is worth more than either implementat...
Searching, sorting, stacks, queues, linked lists, hashing, two pointers, sliding window, trees and graphs in core Python.
6 notes
Linear search checks everything; binary search halves the problem each step. Knowing when the second is possible is worth more than either implementat...
Python sorts for you in n log n. Implementing bubble, insertion, merge and quick sort is still worth doing, because it teaches how algorithms are comp...
Three linear structures defined by where you may add and remove items. Python gives you two of them almost for free; the third is worth building once.
A dictionary turns "have I seen this?" and "how many of these?" from an O(n) scan into an O(1) lookup. That single change solves a large share of inte...
Two techniques that turn a nested loop into a single pass. Two pointers move towards each other; a sliding window grows and shrinks over a range.
A tree is a graph with no cycles and one root. Both are walked with the same two strategies - depth first with a stack, breadth first with a queue.