π FIT2004: Algorithms and Data Structures
Map of Content
Index for FIT2004 Algorithms and Data Structures (Y2S1) β builds on FIT1008_MOC: shared foundations (Big-O, recursion, D&C, merge sort) deepened with correctness proofs and recurrence analysis.
π Assessment Map (2026 S2)
Tiered framework β βEasy to Pass, Hard to Distinction (D/HD).β
| Tier | Marks | Format | Hurdles to sit / pass |
|---|---|---|---|
| Pass β PT1, PT2, PT3 | base | 75-min on-campus closed-book Moodle under SEB | Β§1 binary Competent/Not: (4/5), up to 3 check-attempts per question Β· Β§2 optional written, bonus each |
| Credit β CD1, CD2 | 15-min 1-on-1 Zoom oral, closed-book, screen sharing Β· no reattempts | Β§1 (guided prompts) Β· Β§2 (advanced unguided) Β· needs all PTs Competent, weekly quizzes, timely EOI form | |
| D/HD Exam | 3-hour written paper, on-campus Week 15, closed-book; covers unit content and beyond, high failure/zero-mark rate | all PTs Competent by PTR1, weekly quizzes at 100%, pre-exam score |
- Safety net β PTR1/PTR2 reattempts cover missed competencies, but bonus marks are forfeited.
- PT-03 scope β W9 tries/suffix structures and W10 self-balancing trees β may start from a half-built tree and mix insert with delete Β· no CD question on W10 Β· plus two pass-level flow questions (W11β12 sanity-check doc): run max-flow/min-cut by hand from a blank or mid-stage network (Ford-Fulkerson Method, Min-Cut Max-Flow Theorem) and model a scenario β vertices, directed edges, edge count, capacities, lower bounds, demands (Network Flow Reductions, Circulation with Demands and Lower Bounds).
- LO thread so far β analyse running time via recurrences; design divide-and-conquer algorithms; quote tight Big-O with mandatory complexity tables.
π§° Unit Cheatsheet
- π FIT2004 Unit Cheatsheet β analysis discipline, recurrence regimes, D&C shapes, DP recurrences, per-algorithm bounds
π Knowledge Index
Week 1 β Complexity Analysis, Divide & Conquer, and Solving Recurrences (lecture 1 Β· applied W1)
- Karatsuba Integer Multiplication β Divide and Conquer (NOT EXAMINABLE β lecturer-confirmed motivating hook; read for D&C intuition, never drill it)
- Solving Recurrences (Telescoping) β Big-O Notation (the analysis hand skill β repeated substitution; Master Theorem supplementary)
- Divide and Conquer β Recursion (dual-unit β split/recurse/combine, analysed via recurrences)
- Algorithmic Complexity β Algorithm (dual-unit β input size, RAM model, best/avg/worst; auxiliary space, tightest bound)
- Big-O Notation β Algorithmic Complexity (dual-unit β , dominance, growth ladder)
- Recurrence Relation β Sequence (Mathematics) (dual-unit β the maths behind the running-time recurrences)
- Merge Sort β Divide and Conquer (dual-unit β the canonical )
- Applied 1 (assumed background, re-drilled with ): Arithmetic Series Β· Geometric Series (series bounds for D&C trees) Β· Binary Search Tree (BST) (bound vs case; sorted inserts )
Week 2 β Analysing Recursion: Time and Auxiliary Space (lecture 2 Β· applied W2)
- Analysing Recursive Algorithms (Time and Auxiliary Space) β Recursion (pipeline spine: code β recurrence β time + space; the duplicate-call trap)
- Solving Recurrences (Telescoping) β Big-O Notation (applied: branching Β· prove a given closed form by induction)
- Divide and Conquer β Recursion (applied: Β§3 the three-question checklist for a new problem, and βstrengthen the recursive contractβ)
- Binary Search β Divide and Conquer (dual-unit β decrease-and-conquer; the canonical best worst case)
- Output-Sensitive Complexity β Algorithmic Complexity (range reporting β vs )
- Counting Inversions β Merge Sort (applied P5, flagship LO1: count split inversions in the merge βΉ )
- 2D Local Maximum (Peak Finding) β Divide and Conquer (applied P6: by halving both axes; the correctness argument is the deliverable)
- Fibonacci Sequence β Recurrence Relation (dual-unit β applied P7: matrix identity + doubling identities)
- Applied P8βP17 not noted β P8βP14 repeat telescoping; P15βP17 are lecturer-flagged supplementary (Master Theorem sits in a π block).
Week 3 β Proof of Correctness and the Non-Comparison Sorts (decks p1 Correctness Β· p2 Comparison-Based Β· p3p4 Counting & Radix Β· prep W3 Β· applied W3)
- Invariant β Algorithm (dual-unit β W3 spine: correctness termination loop invariant)
- Binary Search β Divide and Conquer (dual-unit β deepened with the non-termination bug:
lo = midstalls at ) - Sorting Problem β Computational Problem (dual-unit β comparison vs non-comparison, the floor, in-place rule)
- Counting Sort β Sorting Problem (; stability engineered by the prefix-sum position array)
- Radix Sort β Counting Sort ( stable LSD passes, ; base buys linearity)
- K-way Merge β Merge Sort (applied P3
[P,C]β β by swapping the linear scan for a min-Heap) - Online Algorithm β Algorithm (applied P6
[P,C,D]β online vs offline, and the size- max-heap for the smallest) - Prep P3 (radix on
4329, 5169, 4321, 3369, 2121, 2099) duplicates the LSD hand-trace in Radix Sort. - Applied P7βP13 not noted β one-off puzzles; their two keepers are
[D]lines in FIT2004 Unit Cheatsheet Β§9οΈβ£.
Week 4 β QuickSort Deep Dive, Selection, and the Partition Suite (lecture W4 p1/p2 Β· prep W4 Β· applied W4 Β· PT-01)
- Quick Sort β Divide and Conquer (dual-unit β pivot-policy ladder, average height , never in-place)
- Partitioning (Quicksort) β Quick Sort (out-of-place Β· Hoare Β· Lomuto Β· Dutch flag; -partitioning in )
- Quickselect β Divide and Conquer (-th smallest in expected by one-sided recursion; weighted-median adaptations)
- Median of Medians β Quickselect (now examinable β hand execution, the guarantee, )
- Merge Sort β Divide and Conquer (applied: hybrid insertion-sort cut-off)
- Applied P8βP9 already covered in Quickselect β no extra
[P]time.
Week 5 β Graphs, Traversal, and Shortest Paths (lecture W5 p1 Graph Traversal Dijkstra Β· p2 Directed Acyclic Graph Β· applied W5)
- Graph β Binary Relation (dual-unit β , max edges, sparse vs dense)
- Graph Representations β Graph (dual-unit β matrix vs list; the representation sets the bound)
- Uninformed Search (BFS and DFS) ( and unweighted shortest path)
- Dijkstraβs Algorithm β Graph (DP greedy, , proof by contradiction, why negative edges break it)
- Directed Acyclic Graph (DAG) β Types of Graphs (the dependency model; acyclicity is what makes an order exist)
- Topological Sort β Directed Acyclic Graph (DAG) (Kahnβs vs DFS push-on-finish, both )
- Bipartite Graph β Graph (dual-unit, upgraded β DFS two-colouring in , colourings)
- Cycle Detection β Uninformed Search (BFS and DFS) (new β the third
activestate for digraphs; shortest cycle by BFS) - State-Space Graph Modelling β Graph (new, flagship LO1 β put the extra constraint into the vertex)
- Uninformed Search (BFS and DFS) (applied: multi-source super source Β· iterative DFS)
- Topological Sort β Directed Acyclic Graph (DAG) (applied
[D]: guaranteed positions Β· Hamiltonian path iff unique order) - Graph Representations β Graph (applied
[D]: universal sink in ) - Bridges (Low-Link) β Uninformed Search (BFS and DFS) (new,
[D]β every bridge in one DFS)
Week 6 β Minimum Spanning Trees, Union-Find and the Greedy Paradigm (lecture W5 p2 MST Β· prep W6 Β· applied W6)
- Minimum Spanning Tree β Spanning Tree (new hub β edges, cost unique but tree not, negative weights legal)
- Primβs Algorithm β Minimum Spanning Tree (new β Dijkstra with one line changed, )
- Kruskalβs Greedy Algorithm β Minimum Spanning Tree (dual-unit, upgraded β sort
find, cut-and-swap proof) - Union-Find (Disjoint Set) β Set (ADT) (new β
parentarray, union-by-size/rank, path compression) - Greedy Algorithm β Algorithm (new β greedy choice optimal substructure; exchange vs stays-ahead proofs)
- Dijkstraβs Algorithm β Graph (applied: state graphs Β· 0-1 BFS Β· bucket queue)
Week 7 β Dynamic Programming (lecture-06 deck DP Β· DP wrap-up Β· applied W7)
- Dynamic Programming β Algorithm (new β PT-02βs subject: MEMO subproblem, recurrence on the output, reconstruction)
- Coin Change β Dynamic Programming (new β the PT-02 shape: brute force β greedy fails β DP; decision array)
- Knapsack Problem β Dynamic Programming (new β unbounded 1-D vs 0/1 2-D state, both )
- Longest Increasing Subsequence (LIS) β Dynamic Programming (new, applied P4 β anchored βending at β, answer )
- Longest Common Subsequence (LCS) β Dynamic Programming (new, applied P5 β two-prefix grid, ; edit distance lives here)
- Maximum Subarray Sum β Dynamic Programming (new, applied P6 β prefix sums β )
- Interval Dynamic Programming β Dynamic Programming (new β
DP[i][j]filled by increasing length) - Applied P12, P15, P16, P18, P20βP22 not noted β costumes over covered shapes; moves in FIT2004 Unit Cheatsheet Β§1οΈβ£2οΈβ£.
- β οΈ Pass roster: rod cutting unbounded knapsack (not in the deck); edit distance deferred to tutorial videos β held in LCS.
Week 8 β Shortest Paths With Negative Weights (lecture-07 deck Bellman-Ford/Warshall/Floyd-Warshall Β· applied W8)
- Bellman-Ford β Graph (new β negative edges: rounds one check pass, Β· applied P2 super source finds any cycle in Β· P3 walk
predback to extract it) - Floyd-Warshall β Graph (new β all-pairs, ; absorbs Warshallβs transitive closure Β· applied P4
succrebuild in Β· P5 post-process Β· P6 arbitrage on rates) - Johnsonβs Algorithm β Graph (new, applied P1/P7 β a constant shift fails, potentials telescope; sparse all-pairs with negatives in )
- Dijkstraβs Algorithm β Graph (the W8 contrast β the non-negativity these two remove)
- Supplementary P8βP13 not noted β P8 is implementation; P9, P10, P12, P13 share one shape, DP over a DAG in reverse topological order (
[D]line in FIT2004 Unit Cheatsheet Β§1οΈβ£2οΈβ£); P11 (SPFA) is Bellman-Ford with a queue, same worst case.
Week 9 β Tries, Suffix Tries and Suffix Trees (lecture-10 p2 Trie Β· sanity check W9 Β· prep W9 Β· applied W9 Β· PT-03)
- Trie β Tree (new β
$terminal, search, payload augmentation) - Suffix Trie and Suffix Tree β Trie (new β PT-03βs subject: draw, compress, count nodes)
- Suffix array prefix doubling not examinable this semester β one π block in Suffix Trie and Suffix Tree.
Week 10 β Self-Balancing Search Trees (lecture-11 p1 AVL deck Β· sanity check W10 Β· PT-03 notes Β· prep W10 Β· applied W10 Β· no CD content)
- AVL Tree β Binary Search Tree (BST) (new β
h,bfannotation, Ianβs trinode restructure, delete cascades Β· applied P1, P4 proof,[D]P8 height bound) - 2-3 Tree β Tree (new β split promote insert Β· top-down rotate/merge delete, applied P5)
- Left-Leaning Red-Black Tree β 2-3 Tree (new β rotate/flip insert, 2-3 cross-check Β· applied P6 black-height, P5b conversion)
- Binary Search Tree (BST) β Binary Tree (recap β predecessor or successor delete Β· applied P2/P3 proofs, P7 minimal-height build)
Week 11 β Network Flow (lecture-08 deck Network Flow Β· sanity check W11 Β· prep W11 Β· applied W11 Β· PT-03)
- Ford-Fulkerson Method β Graph (new β residual network, augment by bottleneck, pseudo-polynomial Β· sanity check: flow backward weight, capacity forward backward, twin updates, π the argument)
- Min-Cut Max-Flow Theorem β Ford-Fulkerson Method (new β cut capacity vs cut flow; why FF is correct Β· reachability includes backward edges, min cut not unique)
- Network Flow Reductions β Ford-Fulkerson Method (new, the LO1 note β super source, vertex split, matching, disjoint paths Β· credit-discussion P3/P4: the matrix drill and the supercomputer min cut , flipping at penalty )
- Bipartite Graph β Graph (Β§7 pointer β maximum matching is a flow problem)
Week 12 β Circulation with Demands and Lower Bounds (lecture-09 deck Circulation Β· applied W12)
- Circulation with Demands and Lower Bounds β Ford-Fulkerson Method (new β demands via super-edges, lower bounds by pre-push; modelling drills)
- Network Flow Reductions β Ford-Fulkerson Method (applied: DAG path cover Β· project selection Β· fencing)
π Coming later in the unit (from the handbook outline β no notes yet)
- Amortised analysis. (Hashing was removed from the unit in 2025 S1; B-trees continue in FIT3155.)
π§ Suggested Reading Order
(read leftβright Β· bold = competency-test hand skill)
- W1a β analysis first, then the algorithm: Algorithmic Complexity (what we measure) β Big-O Notation (bound vs case) β Arithmetic Series Β· Geometric Series (the summation tools) β Solving Recurrences (Telescoping) (solving ) β Divide and Conquer β Merge Sort end-to-end Β· bounds drill on Binary Search Tree (BST)
- W2a β the whole pipeline on one function: Algorithmic Complexity (Β§6 input vs auxiliary space) β Analysing Recursive Algorithms (Time and Auxiliary Space) (code β recurrence β time + space) β Solving Recurrences (Telescoping) (the branching row) β Binary Search (best worst) β Output-Sensitive Complexity (bounds carrying )
- W2b β the applied sheet, recurrences then new problems: Solving Recurrences (Telescoping) (D4 Β· induction blueprint) β Analysing Recursive Algorithms (Time and Auxiliary Space) (duplicate-call trap) β Divide and Conquer (Β§3 adaptation checklist) β Counting Inversions (instrument the combine) β 2D Local Maximum (Peak Finding) (shrink both axes) β Fibonacci Sequence (Β§4 doubling)
- W3a β prove it, then rank it: Invariant (termination + invariant) β Binary Search (Β§3 non-termination bug) β Sorting Problem (four-axis suite + the floor) β Counting Sort (escape the floor) β Radix Sort (escape the blow-up)
- W3b β the applied suite, in CD1 order: Sorting Problem (Β§5 stability, Β§7 cost terms, Β§8 uses) β K-way Merge (ADT swap βΉ ) β Radix Sort (Β§3 base choice, Β§5 strings) β Online Algorithm (size- heap)
- W4a β partition, then stop sorting: Quick Sort (driver, pivot policy, average case) β Partitioning (Quicksort) (three schemes Dutch flag) β Quickselect (recurse one side) β Median of Medians (the guarantee β now examinable)
- W4b β the applied partition suite: Quick Sort (Β§3 pivot rules) β Partitioning (Quicksort) (naive 3-way Β· -partitioning) β Quickselect (Β§6 adaptations) β Merge Sort (hybrid cut-off)
- W5a β the structure, then the traversal: Graph (directed, weighted, sparse vs dense) β Graph Representations (the bound lives here) β Uninformed Search (BFS and DFS) (, unweighted distance) β Dijkstraβs Algorithm (queue β min-heap)
- W5b β order instead of distance: Directed Acyclic Graph (DAG) (acyclicity is the precondition) β Topological Sort (Kahnβs Β· push-on-finish)
- W5c β the applied sheet, traversal recast: Bipartite Graph (greedy colouring, ) β Cycle Detection (the third state) β Uninformed Search (BFS and DFS) (Β§7 super source) β State-Space Graph Modelling (state in the vertex)
- W5d β the applied sheet, D/HD tier: Topological Sort (Β§4 reachability guarantees Β· Β§5 Hamiltonian path) β Graph Representations (Β§3 universal sink in ) β Bridges (Low-Link) (low-link in one DFS)
- W6a β the object, then the two builders: Minimum Spanning Tree (what is being minimised) β Primβs Algorithm (Dijkstra, one line changed) β Kruskalβs Greedy Algorithm (sort cycle test) β Union-Find (Disjoint Set) (the test, made free)
- W6b β why the greed is allowed: Greedy Algorithm (choice property substructure) β Kruskalβs Greedy Algorithm (Β§4 cut-and-swap) β Minimum Spanning Tree (Β§5 reverse-delete, superset) β Invariant (weak vs sufficient)
- W6c β the applied sheet, shortest paths revisited: Dijkstraβs Algorithm (Β§4 deque Β· bucket queue, Β§5 state graph) β Greedy Algorithm (Β§4 interval scheduling) β Union-Find (Disjoint Set) (Β§Applied the height lemma)
- W7a β the paradigm, then the pass-level pair: Dynamic Programming (MEMO β recurrence β reconstruct) β Coin Change (the PT-02 costume) β Knapsack Problem (1-D vs 2-D state)
- W7b β the applied shapes, credit tier: Longest Increasing Subsequence (LIS) (anchored βΉ scan) β Longest Common Subsequence (LCS) (two prefixes, edit distance) β Maximum Subarray Sum (prefix sums β ) β Interval Dynamic Programming (fill by length)
- W8a β the negative-weight escape hatches: Dijkstraβs Algorithm (where greed dies) β Bellman-Ford ( rounds the check) β Floyd-Warshall (all pairs, ) β Graph Representations (density picks the winner)
- W8b β the applied sheet: Bellman-Ford (Β§5 super source, extract the cycle) β Floyd-Warshall (Β§4 Β· Β§5
succΒ· arbitrage) β Johnsonβs Algorithm (why a shift fails, why potentials work) - W9 β retrieval by character, then by suffix: Trie (the
$terminal, , properties) β Suffix Trie and Suffix Tree (PT-03: draw, compress, count) β Trie (Β§4 payload augmentation) β Suffix Trie and Suffix Tree (Β§4 think in the trie, answer in the tree) - W10 β balance, three ways (PT-03): Binary Search Tree (BST) (why balance) β AVL Tree (trinode restructure) β 2-3 Tree (split Β· rotate Β· merge) β Left-Leaning Red-Black Tree (rotate Β· flip, verify via 2-3)
- W10b β the applied sheet, proofs then trees: Binary Search Tree (BST) (P2/P3 proofs Β· Β§5 min-height build) β AVL Tree (P1 Β· P4 proof Β· P8 height bound) β 2-3 Tree (P5 top-down delete) β Left-Leaning Red-Black Tree (P6 black-height Β· P5b conversion)
- W11 β push, prove, reduce: Graph (directed, weighted) β Ford-Fulkerson Method (residual augment) β Min-Cut Max-Flow Theorem (why it stops at max Β· find the cut) β Network Flow Reductions (build the network) β Bipartite Graph (Β§7 matching)
- W12 β feasibility, then modelling: Ford-Fulkerson Method (the engine) β Circulation with Demands and Lower Bounds (Β§2 super-edges Β· Β§3 pre-push ) β Circulation with Demands and Lower Bounds (Β§4 survey Β· airline Β· roster Β· baseball) β Network Flow Reductions (Β§3 path cover Β· Β§5 edges, project selection, fencing)
π― Learning Outcomes (key skills per week)
- W1 β
- measure cost against input size on the RAM model, splitting space into input auxiliary (in-place auxiliary)
- solve a recurrence by telescoping in the mandated Steps 0β6b format β the required method, not the Master Theorem
- read (recursive calls) and (shrink factor) off code and classify by β root-dominated Β· all-levels-equal Β· leaf-dominated
- derive schoolbook multiply as and the naive D&C split as
- state formally with witnesses, and judge valid separately from tight ( but not )
- prove and by induction, then substitute for and
- drop capped parameters (, βΉ ) and declare the unit-cost assumption
- W2 β
- extract a piecewise recurrence from code, counting call sites not coefficients (
2*f(n//3)is ) - quote auxiliary space as , never total calls (Fibonacci: time, space)
- state a reporting bound with its output size and prove optimality
- telescope to via the series
- prove a given closed form by induction over β the step is , never
- collapse two identical recursive calls into one binding βΉ
- count split inversions in blocks during a merge βΉ
- shrink both matrix axes for peak finding, and justify discarding three quadrants
- read and off the Fibonacci matrix power, eliminating
- extract a piecewise recurrence from code, counting call sites not coefficients (
- W3 β
- prove an algorithm correct with both a loop invariant and a termination argument (the strictly decreasing variant)
- write the invariant first, then code to it β quoted at the end of an iteration when there is no early exit
- state selection sortβs two-clause invariant and insertion sortβs sorted-prefix invariant
- rank the sorting suite on time, auxiliary space and stability β recursion stack counts, so recursive sorts are not in-place
- justify the floor as a claim about comparison-based sorts only
- derive Counting Sortβs and make it stable with the prefix-sum position array
- run Radix Sort LSD-first by hand, justify the stable subsort, and derive time
- trade base against column count , and choose for linear time
- radix-sort ragged strings in (total characters) β length-sort ascending, then sweep with a live-window pointer
- force stability on an unstable sort via a parallel index list, proving time is unchanged
- swap K-way Mergeβs minimum scan for a min-Heap βΉ , and state the root invariant
- classify a problem online vs offline before quoting any bound, picking the size- heap on the opposite extreme
- prove a bound optimal by reduction β singleton lists turn K-way Merge into a sort, inheriting
- let an in-place requirement pick the sort β dedup needs Heapsort, the only -auxiliary option
[D]the comparison model proves , never β optimal comparisons optimal running time
- W4 β
- state which Hoare contract you use β this unitβs returns the pivotβs final index, the textbookβs a split point
- rank partition schemes by writes, switch to the Dutch flag for duplicates, and explain why each is unstable
- state Hoareβs
L_bad/R_badinvariants and the Dutch flagβs four regions, one empty at exit - derive the average-case height from , then by change of base
- say why quicksort is never in-place even with an in-place partition β the stack is auxiliary
- price sort-then-slice at and say why Counting Sort/Radix Sort cannot be assumed
- derive Quickselectβs , and why an exact-median pivot still leaves quicksort
- run Median of Medians by hand on groups of five, check the band, and state the recurrence and why groups of not
- rank pivot policies: randomisation beats the adversary, Median of Medians beats the worst case; constant-fraction splits stay
- generalise partitioning to pivots, , optimal by reduction
- adapt Quickselect to the weighted median and the closest to the median
- W5 β
- state , quote max edges, and classify sparse vs dense before quoting any bound
- pick matrix vs list from the operation mix and state the resulting traversal bound
- derive β each vertex served once, each edge inspected twice β naming the
discoveredflag as the reason no queue scan happens - trace BFS and DFS writing both the
DiscoveredandVisitedrows, getting unweighted distance fromu.distance + 1and the path fromv.previous - explain Dijkstra as dynamic programming greedy, and where the greed dies
- hand-trace Dijkstra, writing every vertexβs distance estimate at every serve
- derive , and place the slideβs as the dense case
- prove Dijkstra correct by contradiction, pointing at the step that spends non-negativity
- define a DAG and say why acyclicity is the existence condition for an order
- run Kahnβs and the push-on-finish DFS, detecting a cycle from a short output, and reject a DFS pre-order as a topological order with the counterexample
- two-colour a graph by greedy DFS, justify why the first colour is free, and count the colourings as over components
- upgrade DFS to three states for a digraph, firing only on an edge into an active vertex, and say why the undirected rule false-positives
- justify β not β for undirected cycle existence, from forest plus early termination
- find the shortest cycle by BFS from every vertex, , and say why one BFS returns the wrong one
- solve multi-source shortest path by super source subtract , and defend transforming the input over modifying the algorithm
- model a constraint as , wire only legal transitions, and answer over all accepting states
[D]universal sink in Β· bridges by low-link Β· guaranteed topological positions Β· DAG Hamiltonian path by unique order
- W6 β
- define an MST and justify exactly edges βΉ only the weights discriminate
- answer βnegative weights in Prim/Kruskal?β β yes: they only compare edges, and a shift moves every tree equally
- derive Prim from Dijkstra (
v.distance = w) and hand-trace it from a named root - hand-trace Kruskal in sorted-edge order with the
findroots, stopping at edges - state the cut-and-swap exchange proof for both MST algorithms, and name the invariant subset of some MST (Kruskal) vs superset of some MST (reverse-delete)
- reject a true but too weak invariant with a counterexample, quoting the rule invariant termination postcondition
- prove that every path in an MST is a bottleneck path, and give a bottleneck path that lies in no MST
- hand-trace union-find in one
parentarray under union-by-size, with path compression - prove by induction βΉ per union βΉ for all unions
- locate the factor in naive Kruskal (in union) and quote
- name the greedy paradigmβs two ingredients and pick the right proof template β exchange for MST, stays ahead for scheduling
- solve interval scheduling by earliest finish time and prove it stays ahead
- replace the priority queue when weights allow β deque for , bucket array for small integers β both
- model an extra resource as a state graph () and run Dijkstra unmodified
- break βupdate only on first discoveryβ with an expensive first route and a cheap later one
- W7 β
- write the output recurrence: base, general and edge cases
- size the MEMO βΉ auxiliary space; time cells work each
- separate DP from divide & conquer: optimal sub-solutions that overlap
- decide the state: is one parameter enough? (unbounded vs 0/1 knapsack)
- rebuild the combination by decision array or backtracking
- W8 β
- justify Bellman-Fordβs rounds and its extra check pass
- find any negative cycle with ONE Bellman-Ford from a weight- super source in , and extract its vertices by walking
predback to a repeat - rebuild a Floyd-Warshall path in from
succ, and post-process every pair through a negative cycle to in - reduce arbitrage to a negative cycle on rates
- break the constant-shift repair with a counterexample, and prove potential reweighting preserves shortest paths by telescoping
- select Dijkstra / Bellman-Ford / Floyd-Warshall / Johnsonβs by weight sign, number of sources and density
- W9 β
- justify the
$terminal and itslinks[0]slot, and quote trie search as with absent - bound a trie by its properties β nodes , leaves , height β and choose it over a sorted array, BST or hash table from the query type
- augment the node payload to answer a query in β prefix count, scored prefix, predecessor
- draw the suffix trie of
S$and compress it to a[start,end]suffix tree - count nodes, inner nodes, leaves and height of both (PT-03)
- solve a substring problem in the suffix trie, then translate it to the tree
- justify the
- W10 β
- annotate every node
h,bfwith and find the lowest node with - classify LL/RR/LR/RL by two steps down the taller side β a tie on step 2 repeats step 1
- restructure by Ianβs way: median up, smaller left, bigger right, re-hung in-order
- delete via predecessor or successor and keep rebalancing up to the root
- justify AVL operations as : stored heights, rotations per fix
- insert into a 2-3 tree by split promote, cascading to a root split
- delete from a 2-3 tree top-down β rotate or merge before entering each 2-node (root first), then split leftover 4-nodes on the way out
- insert into an LLRB as a red leaf and fix by rotate left / rotate right / colour flip, then blacken the root
- convert 2-3 β· LLRB and check equal black-height on every branch
- state the LLRB black-height after each insert, and say why it rises only when red reaches the root
- prove the successor of a two-child node has no left child, and that a new key has exactly one insertion point
- build a minimal-height BST from sorted keys, prove height , and prove optimal by reduction to sorting
[D]prove AVL height via
- annotate every node
- W11 β
- state the capacity constraint and flow conservation, and read off a network
- draw the residual network β forward , backward , zeros dropped, parallels merged
- hand-run Ford-Fulkerson: path, residual bottleneck, augment (cancelling via backward edges), repeat to no path
- derive , call it pseudo-polynomial, and quote BFS (EdmondsβKarp)
- compute a cutβs capacity ( only) and flow (out in), and prove every cut carries
- prove max-flow min-cut from residual reachability, and extract the min cut after FF
- verify a mid-stage PT-03 answer by re-running from blank β same max-flow, possibly a different min cut
- reduce a new problem to max flow β super source/sink, vertex split, matching with quotas, disjoint paths, min-cut split β and state the read-off
- W12 β
- state the demand constraint and read a negative demand as a supplier
- decide circulation feasibility by one max flow β cap , cap , feasible every super-edge saturated
- remove lower bounds by pre-pushing β , β then return
- certify infeasibility with a cut of capacity
- model βat least / at most / exactlyβ as edge windows and demands β survey design, airline scheduling, rosters, baseball elimination
- cap a group of edges with a selector vertex
- reduce DAG minimum path cover to bipartite matching, answer
- encode prerequisites as edges in a min cut and recover profit