Exercise sets
Exercises
Each set teaches one technique. One worked example with self-explanation prompts, five to ten practice problems across varied surface contexts, and two check problems designed to resist pattern-matching. You read the concept page to understand a method; you work the exercise set to acquire the skill.
-
Algorithms 1 worked · 7 practice · 2 check Binary Search →
Recognize a problem as the search for the unique boundary of a monotonic predicate; maintain an invariant interval [lo, hi] with a known predicate sign at each end; halve the interval per step until the boundary is found in O(log n) time.
classic sorted-array lookuplower-bound with duplicatesinteger square rootrotated sorted arraypeak element (local extremum)parametric search (binary search on the answer)real-valued root findingbased on Binary Search
-
Algorithms 1 worked · 7 practice · 2 check Coin Change & Dynamic Programming →
Recognize a problem as having overlapping sub-problems and optimal substructure; identify a state variable and a recurrence that combines smaller solutions into larger ones; tabulate from the base case upward in O(states × choices) time.
count ways (unordered combinations)0/1 knapsack with capacity constraintedit distance between stringslongest common subsequenceclimbing stairs (linear recurrence)subset sum decisionrod cutting / revenue maximizationbased on Coin Change Problem
-
Algorithms 1 worked · 7 practice · 2 check Depth-First Search →
Traverse a graph or tree by following each branch to its end before backtracking. Use the discover/finish timestamps (or coloring scheme: white/gray/black) to derive cycle detection, topological sort, connected components, and reachability — DFS is the substrate for an entire family of graph algorithms.
cycle detection in directed graphtopological sortconnected components (undirected)tree traversal ordersreachability and ancestrymaze / grid path with backtrackingiterative vs recursive implementationbased on Depth-First Search
-
Algorithms 1 worked · 7 practice · 2 check Dijkstra's Algorithm →
Compute single-source shortest paths in a graph with non-negative edge weights by maintaining a priority queue of (tentative distance, vertex) pairs, repeatedly extracting the minimum, marking it final, and relaxing its outgoing edges.
explicit weighted graph tracegrid shortest-path (implicit graph)currency-exchange / multiplicative transformationnegative-edge counterexampleearly termination for single-pair queryBFS as unit-weight Dijkstracounting shortest pathsbased on Dijkstra's Algorithm
-
Algorithms 1 worked · 7 practice · 2 check Heap Sort →
Use a heap (array-indexed binary tree with parent ≥ children) to maintain a partial order that gives O(log n) extract-max and O(log n) insert — the building block of priority queues, top-k, median maintenance, k-way merge, and Dijkstra.
OS task schedulingstreaming top-konline median (two-heap)k-way mergeDijkstra's frontierpartial-heap repairHuffman codingbased on Heap Sort
-
Algorithms 1 worked · 7 practice · 2 check Union-Find →
Recognize a problem as a partition-membership question and reduce it to find/union calls — optionally decorating each component with extra metadata.
image processingtemporal event streamsdecorated union-findalgebraic equivalencetype inferencebipartite graph testingoffline reverse-timebased on Union-Find
-
Machine Learning 1 worked · 7 practice · 2 check Linear Regression →
Recognize a problem as "fit a model that is linear in its parameters," set up the design matrix, solve XᵀXβ = Xᵀy by normal equations or QR, and read coefficient stability vs prediction stability from the conditioning of X.
climate trendsfree-fall physicspolynomial curve fittingeconomic elasticity (log-log)sensor calibrationmulticollinearity diagnosticsweighted least squaresbased on Linear Regression from Scratch
-
Machine Learning 1 worked · 7 practice · 2 check Logistic Regression →
Recognize a problem as binary classification, model P(y=1|x) = σ(xᵀβ), fit by minimizing cross-entropy via gradient descent, then read decision boundary, probability calibration, and odds-ratio interpretation off the learned β.
medical risk scoringmarketing click predictiondecision-boundary geometrypolynomial features for circular dataclass imbalance reweightingcalibration diagnosticssoftmax / multi-class extensionbased on Logistic Regression from Scratch
-
Machine Learning 1 worked · 7 practice · 2 check Self-Learning Monte Carlo →
Compute the SLMC Metropolis-Hastings acceptance α = min(1, exp(-β(ΔH_true − ΔH_eff))) for a proposed move on the surrogate; reason about how surrogate quality, temperature, and proposal structure determine acceptance and overall sampling efficiency.
spin-config bond accountingtemperature scaling of acceptancedetailed-balance verificationsurrogate-quality sensitivityacceptance rate as diagnosticBayesian inference with cheap likelihoodmulti-fidelity Monte Carlo frameworkbased on Self-Learning Monte Carlo
-
Nuclear Physics 1 worked · 7 practice · 2 check Hartree-Fock-Bogoliubov →
Solve the BCS / HFB gap-and-number equations self-consistently for (Δ, λ) given a single-particle spectrum {e_k, Ω_k}, pairing strength G, and target particle number N; read v_k² as the orbital occupation and 2Δ as the excitation gap; identify the critical G below which pairing collapses.
phase transition at critical Gparticle-number tuning via λthree-level extensionexcitation gap from quasi-particle spectrumHF limit recoveryeven-odd mass staggeringsd-shell sub-shell closurebased on Hartree-Fock-Bogoliubov
-
Optimization 1 worked · 7 practice · 2 check Gradient Descent →
Pick a stable step size from the Hessian eigenvalues, run the iteration x ← x − η ∇f(x), and recognize the failure modes (divergence above 2/L, slow progress on ill-conditioned problems, traps on non-convex landscapes).
1D quadratic minimizationill-conditioned 2D quadraticnon-smooth objective (|x|)non-convex landscape, basins of attractionmomentum derivation from physicsdiagonal preconditioninglinear systems via Richardson iterationbased on Gradient Descent
-
Quantum Chemistry 1 worked · 7 practice · 2 check Hartree-Fock SCF →
Recognize a problem as a fixed-point iteration — an operator that depends on its own eigenvector — and solve by iterative refinement: linearize with a guess, solve, use the result to rebuild the operator, iterate. Diagnose convergence, oscillation, and the use of damping or DIIS-style acceleration.
scalar fixed-point analysiscosine fixed-point (Dottie number)power iteration for eigenvectorsoscillation and dampingmean-field self-consistency (Ising)SCF convergence diagnosticscross-domain self-consistencybased on The SCF iteration