πŸ“˜ 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).”

TierMarksFormatHurdles to sit / pass
Pass β€” PT1, PT2, PT3base 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, CD215-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 Exam3-hour written paper, on-campus Week 15, closed-book; covers unit content and beyond, high failure/zero-mark rateall 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)

Week 2 β€” Analysing Recursion: Time and Auxiliary Space (lecture 2 Β· applied W2)

Week 3 β€” Proof of Correctness and the Non-Comparison Sorts (decks p1 Correctness Β· p2 Comparison-Based Β· p3p4 Counting & Radix Β· prep W3 Β· applied W3)

Week 4 β€” QuickSort Deep Dive, Selection, and the Partition Suite (lecture W4 p1/p2 Β· prep W4 Β· applied W4 Β· PT-01)

Week 5 β€” Graphs, Traversal, and Shortest Paths (lecture W5 p1 Graph Traversal Dijkstra Β· p2 Directed Acyclic Graph Β· applied W5)

Week 6 β€” Minimum Spanning Trees, Union-Find and the Greedy Paradigm (lecture W5 p2 MST Β· prep W6 Β· applied W6)

Week 7 β€” Dynamic Programming (lecture-06 deck DP Β· DP wrap-up Β· applied W7)

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 pred back to extract it)
  • Floyd-Warshall β†’ Graph (new β€” all-pairs, ; absorbs Warshall’s transitive closure Β· applied P4 succ rebuild 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)

Week 10 β€” Self-Balancing Search Trees (lecture-11 p1 AVL deck Β· sanity check W10 Β· PT-03 notes Β· prep W10 Β· applied W10 Β· no CD content)

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)

πŸ”­ 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)

🎯 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
  • 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_bad invariants 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 discovered flag as the reason no queue scan happens
    • trace BFS and DFS writing both the Discovered and Visited rows, getting unweighted distance from u.distance + 1 and the path from v.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 find roots, 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 parent array 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 pred back 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 its links[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
  • W10 βž”
    • annotate every node h,bf with 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
  • 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