📘 FIT2004: Algorithms and Data Structures

Map of Content

Index for FIT2004 Algorithms and Data Structures (Y2S1) — rigorous algorithmics building on FIT1008_MOC. Much of the foundational material (Big-O, recursion, divide-and-conquer, merge sort) is shared dual-unit with FIT1008/FIT1058 and deepened here with correctness proofs and recurrence analysis rather than duplicated.

📊 Assessment Map (2026 S2)

  • Tiered grading framework — “Easy to Pass, Hard to Distinction (D/HD).”
  • Pass Tier (Base 50 Marks) — Pass Tests (PT1, PT2, PT3)
    • Format: 75-minute on-campus, closed-book Moodle exams using Safe Exam Browser (SEB).
    • Section 1 (Pass): Binary grade (Competent / Not Competent). Requires ≥80% (4/5) with up to 3 check-attempts per question.
    • Section 2 (Bonus): Optional written questions (+3 bonus marks each).
    • Safety Net: Reattempts (PTR1/PTR2) allowed for missed competencies, but bonus marks are forfeited.
  • Credit Tier (+10 Marks) — Credit Discussions (CD1, CD2)
    • Format: 15-minute 1-on-1 Zoom oral interviews (closed-book, screen sharing). No reattempts.
    • Structure: Section 1 (+3 marks, guided prompts) and Section 2 (+2 marks, advanced unguided follow-up).
    • Prerequisites: Competent in all PTs, completion of ≥50% weekly quizzes, and timely EOI form submission.
  • Distinction / High Distinction Tier (+31 Marks) — D/HD Exam
    • Format: 3-hour written paper exam on-campus in Week 15 (closed-book, high failure/zero-mark rate, covers unit content and beyond).
    • Prerequisites to Sit: Competent in all PTs by PTR1, ≥9/12 weekly quizzes completed (100%), and a pre-exam score of ≥60 marks.
  • LO thread so far ➔ analyse running time via recurrences; design divide-and-conquer algorithms; quote tight Big-O with mandatory complexity tables.

🧰 Unit Cheatsheet

📅 Knowledge Index

Week 1 — Complexity Analysis, Divide & Conquer, and Solving Recurrences (Lectures 1–2)

Applied sheet 1 — assumed background, drilled with the new apparatus:

Lecture 2 — the recursion analysis pipeline:

Week 2 — Proof of Correctness and the Sorting Suite (decks p1 Correctness · p2 Comparison-Based · p3p4 Counting & Radix)

  • Invariant Parent Framework: Algorithm (dual-unit — the W2 spine: correctness termination loop invariant; owns the exam protocol “explain why this algorithm is correct”)
  • Binary Search Parent Framework: Divide and Conquer (dual-unit — deepened with the non-termination bug: lo = mid stalls at )
  • Sorting Problem Parent Framework: Computational Problem (dual-unit — deepened with comparison vs non-comparison, the floor, the comparison-cost multiplier, and the recursion-stack/in-place rule)
  • Counting Sort Parent Framework: Sorting Problem (non-comparison — ; stability must be engineered via a prefix-sum position array)
  • Radix Sort Parent Framework: Counting Sort ( stable counting passes, LSD first — ; stability is load-bearing)

Applied sheet 2 — recurrences drilled, then D&C applied to two UNSEEN problems:

  • Solving Recurrences (Telescoping) Parent Framework: Big-O Notation (deepened: P1 branching-by-subtraction · P3 the Proof Blueprint — proving a GIVEN closed form by induction over , i.e. not )
  • Analysing Recursive Algorithms (Time and Auxiliary Space) Parent Framework: Recursion (deepened: P4 the duplicate-call trapPOW(x,p/2)*POW(x,p/2) is , binding it once is )
  • Counting Inversions Parent Framework: Merge Sort (P5 — the flagship LO1 note: instrument the merge, count split inversions in blocks, )
  • 2D Local Maximum (Peak Finding) Parent Framework: Divide and Conquer (P6 — on an input; the correctness argument is the deliverable, and halving ONE axis silently costs )
  • Fibonacci Sequence Parent Framework: Recurrence Relation (dual-unit — P7 deepens it with the matrix identity by induction and the / doubling identities that halve the index)
  • Divide and Conquer Parent Framework: Recursion (deepened: §4 the three-question checklist for adapting D&C to a new problem, and “strengthen the recursive contract”)
  • Supplementary problems 8–17 deliberately not noted — P8–P14 are telescoping repetitions of P1–P3, and P15 (Master Theorem proof), P16 (Strassen) and P17 (the substitution) are lecturer-flagged supplementary. The Master Theorem already sits as a 🔭 block in Solving Recurrences (Telescoping).

Week 3 — QuickSort Deep Dive, Selection, and the Applied Sorting Suite (lecture W3 · applied W3 · PT-01)

  • Quick Sort Parent Framework: Divide and Conquer (dual-unit — deepened: Lomuto vs Hoare vs 3-way partition, the pivot-policy ladder, and how to make the worst case impossible)
  • Quickselect Parent Framework: Divide and Conquer (the -th smallest — one-sided recursion turns into expected)
  • Median of Medians Parent Framework: Quickselect (quiz-only — lecturer-stated as historically not examinable in the final exam; own the guarantee and the recurrence, do not drill it as a hand skill)
  • Counting Sort Parent Framework: Sorting Problem (deepened: negative-key offset mapping, and the PT-01 rule for bucket vs count+position variant)
  • Radix Sort Parent Framework: Counting Sort (deepened: base is what buys linearity; string optimisation by length and alignment)

Applied sheet 3 — the CD1 problem set, tier tags as issued:

  • Sorting Problem Parent Framework: Computational Problem (deepened: §6 forcing stability [P,C,D] · §8 the dropped cost terms · §9 what sorting is FOR, incl. two-pointer dedup [C,D,HD])
  • K-way Merge Parent Framework: Merge Sort (Problem 3 [P,C] by swapping the linear scan for a min-Heap)
  • Online Algorithm Parent Framework: Algorithm (Problem 6 [P,C,D] — online vs offline, and the size- max-heap for the smallest)
  • The supplementary problems 7–13 are deliberately not noted — one-off puzzles with no transferable pattern; solve them from the PDF if they come up. The only two ideas worth keeping (the comparison model bounds only from below; “in-place” depends on the cost model) live as [D] lines in FIT2004 Unit Cheatsheet §9️⃣.

🔭 Coming later in the unit (from the handbook outline — no notes yet)

  • Amortised analysis · greedy algorithms · dynamic programming (the king — recurrence → memo table → trace) · balanced BSTs (AVL), B-trees, tries, union-find · graph algorithms (BFS/DFS, Dijkstra, Bellman-Ford, Floyd-Warshall, MST, topological sort, network flow) · hashing.

🧭 Suggested Reading Order

(read left→right · bold = competency-test hand skill)

🎯 Learning Outcomes (key skills per week)

  • W1
    • measure cost as a function of input size (often bit-length) on the RAM model; distinguish total vs auxiliary space; quote the tightest () bound
    • set up a running-time recurrence for a recursive algorithm
    • solve it by telescoping written in the mandated Steps 0→6b exam format (levels → substitute → general form in → fix from the base → closed form → complexity → verify base + general) — the required method: it covers and and yields , where the Master Theorem covers only and yields
    • derive schoolbook multiplication as and the naive D&C split as
    • read (recursive calls) and (shrink factor) off code and classify by — root-dominated · all-levels-equal · leaf-dominated
    • state formally with witnesses; judge a bound valid separately from tight ( is TRUE, FALSE)
    • pair every bound with a case — “any operation” bounds cheapest/dearest, so an unqualified needs them to agree
    • prove and by induction, then substitute for and
    • drop capped parameters from a bound (, ) and declare the unit-cost assumption
    • split space into input auxiliary, label auxiliary in-place, and time auxiliary space
    • extract a piecewise recurrence from code — base at the guard threshold, general
    • count as call sites, not coefficients — 2*f(n//3) is , f(n//3)+f(n//3) is
    • quote auxiliary space as , never — hence Merge Sort’s
    • separate time from space on a branching recursion (Fibonacci time, space)
    • state a reporting bound with its output size and prove optimality
  • W2
    • prove an algorithm correct by stating both obligations — loop invariant and termination
    • write a termination argument as finite domain · known start · monotone update (find_min)
    • name the variant that strictly decreases, and spot where it fails (lo = mid at )
    • write the invariant first, then code to it — minimal, data-mentioning, implies the postcondition
    • state selection sort’s two-clause invariant and insertion sort’s sorted-prefix invariant
    • rank the sorting suite on four axes: correctness, time (B/A/W), auxiliary space, stability
    • multiply every comparison-based bound by the comparison cost ,
    • count the recursion stack as auxiliary ⟹ recursive sorts are not in-place,
    • justify the floor as a claim about comparison-based sorts only
    • derive Counting Sort’s and engineer stability via the prefix-sum position array
    • reject the bucket-space misconception — buckets partition
    • run Radix Sort LSD-first by hand and justify why the subsort must be stable
    • derive time, space, and auxiliary (no )
    • trade base against column count , and pad ragged keys
    • 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
    • distinguish Lomuto’s final pivot index from Hoare’s split point — and the recursive call each demands
    • pick a partition scheme by swap count, and reach for 3-way once duplicates are common
    • rank pivot policies by what each removes — randomisation kills the adversary, Median of Medians kills the case
    • show a constant-fraction split () is still ; only constant-size splits are
    • derive Quickselect’s and say where quicksort’s went
    • state the Median of Medians recurrence, and why groups of not
    • 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, and pick the size- heap on the opposite extreme
    • choose radix base and prove ; map negative keys by offset in Counting Sort
    • 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
    • radix-sort ragged strings in (total characters) — length-sort ascending, then sweep with a live-window pointer
    • [D] the comparison model proves , never — optimal comparisons optimal running time