CS205 Data Structures

Complete Teaching Plan & Lecture Notes

Unit 1 — Linear Structures Unit 2 — Analysis & Recursion Unit 3 — Priority Structures Unit 4 — Associative Structures Unit 5 — Trees Unit 6 — Graphs

15 Enhanced Slide Decks  |  370+ Interactive Slides

Each deck includes Canvas visualizations, step-through animations, playgrounds, and challenge quizzes.

Use arrow keys or buttons to navigate

Semester at a Glance

W1-2 Linked Lists (27 slides)

Singly linked list: nodes, traversal, insert/delete, time complexity

W3 Algorithm Analysis (24 slides)

Big-O, growth rates, best/worst/average case, empirical analysis

W4 Recursion (24 slides)

Base/recursive cases, call stack, tail recursion, divide & conquer

W5 Stacks (23 slides)

LIFO, array/linked implementations, parentheses matching, postfix eval

W6 Queues (23 slides)

FIFO, circular array, linked implementation, BFS preview, deque

W7 ArrayLists / NodeLists (23 slides)

Dynamic arrays, amortized analysis, positional lists, iterators

W8 Midterm Review

Units 1-2 assessment: linked lists through array lists

W9 Priority Queues (24 slides)

PQ ADT, sorted/unsorted list implementations, comparators

W10 Heaps (26 slides)

Binary heap, array representation, upheap/downheap, heapsort

W11 Maps & Hash Tables (22+26 slides)

Map ADT, hash functions, collision handling, load factor, rehashing

W12 Trees (28 slides)

Binary trees, BST, traversals, balanced trees (AVL preview)

W13 Graphs (26 slides)

Graph terminology, representations, adjacency matrix/list

W14 BFS & DFS (24+23 slides)

Traversal algorithms, applications, edge classification, topological sort

W15 Shortest Path (24 slides)

Dijkstra's, Bellman-Ford, negative cycles, applications

How to Use the Enhanced Decks

Lecture Flow Pattern

1. Concept Introduction (static slides)

Present the concept with text, analogies, and key-idea boxes. Let students read and absorb.

2. Live Demo (interactive slides)

Step through the algorithm on Canvas. Use "Step" button for manual pace, "Auto Play" to show the full flow. Reset and re-run for emphasis.

3. Student Challenge (inline quizzes)

Pause at sCA/sCB/sCC slides. Give students 2-3 minutes to predict, then reveal. Great for think-pair-share.

4. Final Assessment (sQ1-sQ3)

Use as exit ticket or start of next class. sQ1 = quick check, sQ2 = trace, sQ3 = code prediction.

Interactive Element Types

Step-Through

Algorithm animations with Step / Auto / Reset. Code lines highlight in sync with Canvas.

Playground

Students input values and watch operations animate. Great for "what if" exploration.

Comparison Toggle

Side-by-side or toggle views (e.g., BFS vs DFS, sorted vs unsorted PQ). Ask "when would you pick each?"

Challenge Slides

sCA = Predict/Trace, sCB = Fix the Bug, sCC = Decision Scenario. Interleaved after teaching sections.

Keyboard Tips

  • Arrow keys navigate slides (disabled when input focused)
  • All decks are self-contained HTML — open in any browser
  • Resize browser for different projector resolutions

Unit 1 Linked Lists

linked-list-enhanced.html  |  27 slides  |  ~75 min

Learning Objectives

  1. Understand node-based storage vs contiguous arrays
  2. Implement insert/delete at head, tail, and middle
  3. Trace pointer manipulation step-by-step
  4. Analyze O(1) insert-at-head vs O(n) search

Key Demos to Run

Step-Through Insert at Head / Tail

Show pointer rewiring. Pause after each step — ask "which pointer changes first and why?"

Playground Interactive Insert/Delete/Search

Let students call out values to insert. Then ask them to predict what happens on delete.

Common Misconceptions

Order of pointer updates matters!

If you update head = newNode before newNode.next = head, you lose the list. Demo this with the step-through to make it visceral.

Linked list ≠ faster than array

Students assume linked lists are "better." Emphasize: O(n) search, no random access, extra memory per node. Arrays win on cache locality.

Discussion Questions

  • "When would you choose a linked list over an array?"
  • "Why does Java's LinkedList implement both List and Deque?"
  • "What happens if you forget to update the tail pointer on delete-last?"

Challenge Slides

sCA Predict final list after operations   sCB Find the null-pointer bug   sCC Array vs Linked List scenarios

Unit 2 Algorithm Analysis

algorithm-analysis-enhanced.html  |  24 slides  |  ~65 min

Learning Objectives

  1. Distinguish O, Ω, Θ notations with formal definitions
  2. Rank common growth rates: O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(2ⁿ)
  3. Analyze loops to derive Big-O
  4. Understand best/worst/average case

Key Demos to Run

Growth Rate Race

Animated bar chart showing how functions grow as n increases. Students are always shocked how fast 2ⁿ explodes.

Loop Counter

Step through nested loops, watch the operation counter. Ask "what happens if we double n?"

Common Misconceptions

O(n) means "exactly n operations"

Emphasize: Big-O is an upper bound on growth rate, not exact count. 3n+5 is still O(n).

Confusing O, Ω, and Θ

Use the sandwich analogy: Θ = tight fit, O = ceiling, Ω = floor. The interactive slide lets students toggle between them.

Teaching Tips

  • Start with concrete examples before formal definitions
  • Use the "doubling test": if n doubles, how does time change?
  • Have students guess complexity before revealing — builds intuition
  • Relate back to linked list: "now we can formally say insert-at-head is O(1)"

Unit 2 Recursion

recursion-enhanced.html  |  24 slides  |  ~70 min

Learning Objectives

  1. Identify base case and recursive case
  2. Trace the call stack for factorial, Fibonacci, etc.
  3. Understand stack overflow and tail recursion
  4. Apply recursion to divide-and-conquer problems

Key Demos to Run

Call Stack Visualizer

Step through factorial(5) watching frames push/pop. Code lines highlight in sync. This is the "aha moment" slide.

Fibonacci Tree

Watch the recursion tree grow exponentially. Visually devastating — perfect for motivating memoization later.

Common Misconceptions

"Recursion is just a loop"

Show the call stack — each call has its OWN variables. The stack visualizer makes this click. Then show problems that are natural for recursion but awkward with loops (tree traversal).

Forgetting the base case

Demo what happens without a base case — stack overflow. Use the "Fix the Bug" challenge slide.

Teaching Sequence

  1. Start with factorial — simplest recursive structure
  2. Show call stack animation — build mental model
  3. Move to Fibonacci — introduce overlapping subproblems
  4. Tower of Hanoi — recursion as problem decomposition
  5. Binary search — connect to real algorithm

Unit 1 Stacks

stacks-enhanced.html  |  23 slides  |  ~55 min

Learning Objectives

  1. Understand LIFO principle and ADT operations
  2. Implement with array and linked list
  3. Apply to parentheses matching and postfix evaluation
  4. Connect to recursion (call stack is a stack!)

Key Demos

Parentheses Matcher

Type an expression — watch stack push on '(' and pop on ')'. Try unbalanced cases. Students love seeing it fail on "{[}]".

Postfix Evaluator

Step through "3 4 + 2 *" — watch operands push and operators pop two + push result. Great for "trace the stack" exercises.

Teaching Connection

Bridge from Recursion

"Remember the call stack from last week? That IS a stack. Now we're building the data structure explicitly." This callback makes stacks feel motivated rather than arbitrary.

Discussion Questions

  • "Your browser's back button — stack or queue?"
  • "Undo/redo uses two stacks. How?"
  • "Why is array-based stack typically preferred over linked list?"

Common Pitfalls

Stack underflow

Students forget to check isEmpty() before pop(). Use the challenge slide to show this bug.

Unit 1 Queues

queues-enhanced.html  |  23 slides  |  ~55 min

Learning Objectives

  1. Understand FIFO principle and ADT operations
  2. Implement circular array queue (wrap-around)
  3. Contrast with stack applications
  4. Preview BFS as a queue-based algorithm

Key Demos

Circular Array

Watch front/rear pointers wrap around. Enqueue until full, then dequeue — the "circular" nature becomes obvious visually.

Stack vs Queue Race

Same input, different order. Students see LIFO vs FIFO side-by-side. Ask "which is better for a printer queue?"

Teaching Connection

Stack vs Queue Comparison

Teach queues immediately after stacks. The comparison toggle slide is powerful — same operations, opposite behavior. Students remember the contrast better than either in isolation.

Common Misconceptions

Circular array: "full" vs "empty"

Both look like front==rear! Solutions: waste one slot, or use a count variable. Demo both approaches — ask which is better.

Foreshadowing

  • "We'll see queues again in BFS — the queue determines the traversal order"
  • "Priority queues are coming — what if the queue doesn't serve FIFO?"

Unit 1 ArrayLists / NodeLists

arraylists-enhanced.html  |  23 slides  |  ~60 min

Learning Objectives

  1. Understand dynamic array resizing strategy
  2. Analyze amortized O(1) for add-last
  3. Compare array list vs linked list tradeoffs
  4. Understand positional lists and iterators

Key Demos

Dynamic Resizing

Watch array double when full. The cost counter shows expensive copies happen rarely — perfect for introducing amortized analysis.

Shift Animation

Insert at index 0 — watch ALL elements shift right. Makes O(n) insert-at-front viscerally obvious.

Key Concept: Amortized Analysis

This is many students' first encounter with amortized reasoning. Use the "banker's method" analogy: each cheap insert "saves up" credit for the occasional expensive resize.

The resize counter demo is the killer slide here — show n insertions, count total copies, verify it's O(n) total → O(1) amortized.

Unit 1 Wrap-Up Connection

The Full Picture

After this lecture, students have seen 4 linear structures. Draw a comparison table on the board: Linked List vs Array vs Stack vs Queue — operations, time complexity, use cases. This is great midterm review material.

Unit 3 Priority Queues

priority-queues-enhanced.html  |  24 slides  |  ~60 min

Learning Objectives

  1. Define PQ ADT: insert with priority, removeMin
  2. Compare sorted vs unsorted list implementations
  3. Understand why both are O(n) for one operation
  4. Motivate the need for heaps

Key Demos

Sorted vs Unsorted Toggle

Same sequence of inserts — sorted list keeps order (O(n) insert, O(1) removeMin) vs unsorted list (O(1) insert, O(n) removeMin). The visual comparison is eye-opening.

Teaching Strategy

Motivate Before Defining

Start with: "Emergency room triage — who gets treated first?" Not FIFO (that's a regular queue). The person with highest priority. NOW define PQ.

The Tradeoff Slide is Key

Both implementations have one O(n) operation. "Can we get BOTH in O(log n)?" → This is the perfect cliffhanger for introducing heaps next class.

Foreshadowing

  • "Next class: heaps give us O(log n) for both operations"
  • "Dijkstra's algorithm (Week 15) uses a PQ — the choice of PQ implementation affects the algorithm's speed"

Unit 3 Heaps

heap-enhanced.html  |  26 slides  |  ~75 min

Learning Objectives

  1. Understand heap-order property and complete tree shape
  2. Map between tree and array representations
  3. Implement upheap (insert) and downheap (removeMin)
  4. Understand bottom-up heap construction O(n)
  5. Apply to heapsort

Key Demos

Upheap / Downheap Animation

The tree + array dual view is the signature slide. Watch the node bubble up the tree while the array swaps below. Students see the correspondence instantly.

Heapsort Playground

Enter any array, watch build-heap then repeated extractMin. Sorted output accumulates on the right. Compare with selection sort.

Common Misconceptions

Heap ≠ BST

Students confuse heap-order with BST-order. In a min-heap, left child can be larger than right child! The tree visualization makes this clear.

Array indexing confusion

parent(i) = (i-1)/2, children = 2i+1, 2i+2. Drill this with the challenge slide — students predict positions.

Key Insight to Emphasize

Bottom-up construction is O(n), not O(n log n)

This is unintuitive. Use the step-through to show that most nodes are near the bottom (short downheap), few are near the top (long downheap). The sum telescopes.

Unit 4 Maps & Hash Tables

maps-enhanced.html (22) + hashtables-enhanced.html (26)  |  ~2 lectures, 120 min total

Lecture 1: Maps (maps-enhanced.html)

  1. Map ADT: get, put, remove, containsKey
  2. Unsorted list-based map: O(n) everything
  3. Applications: word frequency, symbol table
  4. Motivate: "can we do better than O(n)?" → hashing

Lecture 2: Hash Tables (hashtables-enhanced.html)

  1. Hash functions: mod, MAD, polynomial rolling
  2. Collision handling: chaining vs open addressing
  3. Load factor, rehashing, amortized O(1)
  4. When hashing goes wrong: clustering, worst case O(n)

Key Demos

Hash Function Playground

Students type keys, see hash values and bucket assignments. Try "bad" hash functions (always returns 0) → everything clusters.

Chaining vs Probing Toggle

Same insertions, two collision strategies side-by-side. Watch chains grow vs linear probing clusters form.

Rehashing Animation

Load factor crosses 0.75 → table doubles → all elements re-hash into new positions. Connects back to ArrayList resizing.

Common Misconceptions

"Hash tables are always O(1)"

Average case O(1) with good hash + low load. Worst case O(n) if everything collides. Show the clustering demo.

Unit 5 Trees

trees-enhanced.html  |  28 slides  |  ~80 min

Learning Objectives

  1. Tree terminology: root, parent, child, depth, height
  2. Binary tree properties and traversals (pre/in/post/level)
  3. BST operations: search, insert, delete
  4. BST worst case → motivation for balanced trees

Key Demos

Traversal Animations

Toggle between preorder, inorder, postorder, level-order on the SAME tree. Watch the visit order change. Ask "which gives sorted output for a BST?"

BST Playground

Insert values, watch tree grow. Insert sorted data → degenerates to linked list! Then insert random data → balanced. This is the key visual for motivating AVL/Red-Black.

Teaching Strategy

Build from Known Structures

"A linked list is a degenerate tree (each node has one child). A heap IS a tree (but with different ordering). BST combines the search efficiency of binary search with the flexibility of a linked structure."

Common Misconceptions

BST delete with two children

The "find inorder successor" step confuses students. Use the step-through to show: find min in right subtree, copy value, delete that node. Walk through 2-3 examples.

Height vs Depth confusion

Height = longest path DOWN to leaf. Depth = path UP to root. The interactive tree lets students click nodes and see both values.

Unit 6 Graphs

graph-enhanced.html  |  26 slides  |  ~70 min

Learning Objectives

  1. Graph terminology: vertex, edge, path, cycle, degree
  2. Directed vs undirected, weighted vs unweighted
  3. Representations: adjacency matrix vs adjacency list
  4. Analyze space/time tradeoffs of representations

Key Demos

Build-a-Graph Playground

Click to add nodes, drag to add edges. Toggle directed/undirected. Watch the adjacency matrix AND adjacency list update in real time. Students see the dual representation.

Matrix vs List Space Comparison

Toggle between sparse and dense graph — see matrix mostly empty (wasted space) vs list compact. Then dense → matrix fills up, list gets huge too.

Teaching Strategy

Real-World Motivation

Start with: "Social networks, road maps, the internet, course prerequisites — these are ALL graphs." Show 3-4 examples before formalizing. Students need to see WHY before WHAT.

This Lecture Sets Up Everything

BFS, DFS, Dijkstra, Bellman-Ford all build on this vocabulary and these representations. Spend extra time on adjacency list since most algorithms use it.

Common Misconceptions

"Trees aren't graphs"

A tree IS a graph (connected, acyclic). This connection helps students see graphs as a generalization of everything they've learned.

Unit 6 BFS

bfs-enhanced.html  |  24 slides  |  ~65 min

Learning Objectives

  1. Understand BFS as level-by-level exploration
  2. Implement with queue + visited set
  3. BFS finds shortest path in unweighted graphs
  4. Applications: social network distance, web crawling

Key Demos

BFS Step-Through

Watch the queue state, visited set, and "discovery frontier" expand level by level. The level-coloring makes the "ripple" pattern obvious.

Shortest Path (Unweighted)

Click any two nodes — BFS finds the shortest path. Ask "why does BFS guarantee shortest path in unweighted graphs?" (Because it explores by distance.)

Teaching Connection

Queue → BFS, Stack → DFS

This is the single most important insight. "Replace the queue with a stack and you get DFS." The data structure choice determines the traversal pattern. Callback to Weeks 5-6!

Lecture Flow

  1. Motivate: "find the fewest hops between two people on Facebook"
  2. Show BFS algorithm with queue visualization
  3. Step through example — emphasize level-by-level
  4. Prove: BFS finds shortest unweighted path
  5. Applications: social network, web crawling, maze solving
  6. Challenge: predict BFS order on a new graph

Unit 6 DFS

dfs-enhanced.html  |  23 slides  |  ~70 min

Learning Objectives

  1. Understand DFS as "go deep, then backtrack"
  2. Recursive and iterative (stack-based) implementations
  3. Edge classification: tree, back, forward, cross
  4. Applications: cycle detection, topological sort, SCCs

Key Demos

DFS with Call Stack

Watch the recursion call stack grow and shrink alongside the graph traversal. Discovery/finish times animate on a timeline.

BFS vs DFS Toggle

Same graph, toggle between BFS and DFS — dramatically different traversal orders. Ask "when would you prefer each?"

Topological Sort

Course prerequisite DAG — DFS finish order reversed gives valid course sequence. Students see why it works.

Teaching Strategy

Teach BFS and DFS Together

Cover BFS and DFS in consecutive lectures. The comparison slide is essential — same graph, different structure. Students who see them side-by-side retain both better.

Deep Dive Topics

Edge Classification (advanced)

WHITE/GRAY/BLACK coloring determines edge types. Back edge → cycle. This is beautiful theory but can overwhelm — gauge the class. The step-through with colors helps enormously.

Challenge Highlight

sCB — Fix the Bug

Missing visited check → infinite loop. This is the most impactful bug-fix challenge. Students who debug this remember to check visited forever.

Unit 6 Shortest Path

shortest-path-enhanced.html  |  24 slides  |  ~80 min

Learning Objectives

  1. Understand edge relaxation as the core operation
  2. Dijkstra's: greedy + PQ, O(E log V), non-negative only
  3. Bellman-Ford: V-1 iterations, handles negative weights
  4. Detect negative cycles with the V-th pass
  5. Choose the right algorithm for the scenario

Key Demos

Dijkstra Cloud Expansion

The "expanding cloud" visualization makes the greedy choice intuitive. Step through with PQ + dist table in sync.

Dijkstra FAILS Demo

Run Dijkstra on a negative-weight graph — watch it produce the WRONG answer. Then run Bellman-Ford on the same graph — correct! This contrast is unforgettable.

Teaching Strategy

Build Up to the Limitation

Spend 40 min on Dijkstra (slides 1-10): concept, relaxation, full trace. Students should feel confident. THEN drop the bomb: "it breaks with negative weights." The failure demo creates cognitive tension that motivates Bellman-Ford.

Edge Relaxation Interactive

Slide 6 lets students enter dist[u], weight, dist[v] and see if relaxation triggers. Use this early — if students grok relaxation, both algorithms are easy.

Capstone Connection

Everything Comes Together

Dijkstra uses: graphs (W13), PQ/heap (W9-10), greedy strategy. Bellman-Ford uses: edge relaxation (DP pattern). BFS = unweighted shortest path. This lecture ties the whole course together.

Assessment Strategy

In-Class (using Enhanced Slides)

Think-Pair-Share at Challenge Slides

Every deck has 3 inline challenges (sCA, sCB, sCC). Pause, give 2-3 min, have students discuss with a partner, then reveal. Great for formative assessment.

Exit Tickets (sQ1-sQ3)

Final 3 slides of each deck are quiz questions. Use as end-of-class check: sQ1 = quick multiple choice, sQ2 = trace exercise, sQ3 = predict code output. Collect responses via hand-raise or clicker.

Live Coding Challenges

After the playground demo, ask a student to "predict what happens if we insert 42" before clicking. Builds active engagement.

Exam Question Types

Type 1: Trace an Algorithm

"Show the state of the heap after inserting 5, 3, 8, 1, 7." Mirrors the step-through animations — students who practiced with interactive slides ace these.

Type 2: Compare & Choose

"For each scenario, which data structure is best?" Mirrors the sCC challenge slides. Tests deeper understanding.

Type 3: Complexity Analysis

"What is the time complexity of X using Y?" Requires connecting structure to operations.

Type 4: Code Bug / Fix

"This code has a bug. Identify and fix it." Mirrors sCB slides. Tests practical understanding.

Suggested Exam Split

Midterm: Units 1-2 (Weeks 1-7)
Final: Units 3-6 (Weeks 9-15), cumulative

Concept Dependency Map

How topics connect — use this to emphasize callbacks during lectures

Complexity Cheat Sheet

Quick reference for all data structures covered

Enhanced Deck Quick Reference

All 15 decks with slide counts and key interactive features

U1 linked-list-enhanced.html (27 slides)
Step-through insert/delete, interactive playground, SVG diagrams
U2 algorithm-analysis-enhanced.html (24 slides)
Growth rate race, loop counter, O/Ω/Θ toggle
U2 recursion-enhanced.html (24 slides)
Call stack visualizer, Fibonacci tree, Tower of Hanoi
U1 stacks-enhanced.html (23 slides)
Parentheses matcher, postfix evaluator, push/pop animation
U1 queues-enhanced.html (23 slides)
Circular array viz, stack vs queue race, BFS preview
U1 arraylists-enhanced.html (23 slides)
Dynamic resizing, shift animation, amortized counter
U3 priority-queues-enhanced.html (24 slides)
Sorted vs unsorted toggle, PQ operations, comparator demo
U3 heap-enhanced.html (26 slides)
Upheap/downheap with tree+array, build-heap, heapsort playground
U4 maps-enhanced.html (22 slides)
Map operations, list-based implementation, word frequency
U4 hashtables-enhanced.html (26 slides)
Hash playground, chaining vs probing, rehashing animation
U5 trees-enhanced.html (28 slides)
4 traversal animations, BST playground, delete step-through
U6 graph-enhanced.html (26 slides)
Build-a-graph, matrix vs list, directed/undirected toggle
U6 bfs-enhanced.html (24 slides)
Level-by-level BFS, queue state, shortest path demo
U6 dfs-enhanced.html (23 slides)
Call stack + graph, edge classification, topological sort, maze
U6 shortest-path-enhanced.html (24 slides)
Dijkstra cloud, relaxation interactive, Bellman-Ford, neg cycle
Total: 367 interactive slides
Each with Canvas visualizations, step-throughs, and challenge quizzes