On this page
Problem-Solving Patterns
Prev: Trees, Heaps & Graphs | Up: algorithms_and_dsa | Next: concurrency
Rel: Complexity & Big-O Notation
Ref: Wikipedia — Dynamic Programming
Tags: #public #prog #programming #algorithms
Contents
Core Algorithmic Techniques
- Binary Search: halves a sorted search space (or any monotonic predicate
false, false, ..., true, true) in $O(\log n)$. - Two Pointers: moves two indices inward or in tandem across a sorted array/string in $O(n)$ time and $O(1)$ space.
- Sliding Window: expands and shrinks a contiguous
[left, right]subarray to maintain a running invariant (sums, distinct counts) in $O(n)$. - Divide & Conquer: splits a problem into independent subproblems, solves them recursively, and merges results (merge sort, quicksort).
- Greedy: picks the locally optimal choice at each step when the problem has the greedy-choice property (interval scheduling, Huffman coding).
Dynamic Programming (Memoization vs. Tabulation)
Applies when a problem has overlapping subproblems and optimal substructure:
- Top-down (Memoization): write the natural recursive relation and cache results by state key.
- Bottom-up (Tabulation): fill a table iteratively from smallest subproblems upward (often reducible to $O(1)$ or $O(n)$ space).
Linked from
Related notes
- tuts/programming/algorithms_and_dsa Linked here; links to this page; shared tags: #algorithms, #prog, #programming
- tuts/programming/algorithms_and_dsa/trees_heaps_and_graphs Linked here; links to this page; shared tags: #prog, #programming
- tuts/programming/algorithms_and_dsa/complexity_and_big_o Linked here; shared tags: #algorithms, #prog, #programming
- tuts/programming/concurrency Linked here; shared tags: #prog, #programming
- tuts/cpp/stdlib/algorithm_and_ranges shared tags: #algorithms, #prog
- tuts/cpp/stdlib/algorithm_and_ranges/find_if shared tags: #algorithms, #prog
- tuts/cpp/stdlib/algorithm_and_ranges/sort shared tags: #algorithms, #prog
- tuts/cpp/stdlib/algorithm_and_ranges/transform shared tags: #algorithms, #prog
- tuts/programming shared tags: #prog, #programming
- tuts/programming/algorithms_and_dsa/linear_and_hashed_structures shared tags: #prog, #programming