Back
COMP2521 · Practice
Past Exam Problems
21T3 Q6 — Stable sort of students
21T3 Q7 — Is the digraph a binary tree?
21T3 Q8 — Sum of odd values (rebuild tree)
21T3 Q9 — Number of reachable vertices
24T2 Q8 — Append two lists
24T2 Q9 — Longest increasing run
24T2 Q10 — Max |in-deg − out-deg|
24T2 Q11 — Day trip
24T2 Q12 — Min difference on a BST level
Worked Examples by Topic
Arrays: Longest Strictly-Increasing Run
Arrays: Reverse In Place
AVL Tree: Self-balancing Insert
AVL Tree: Height After Inserts
Complexity: Count a Triangular Double Loop
Complexity: Multiplications in Matrix Multiply
BST: Insert & Search
BST: k-th Smallest
Binary Tree: Height
Binary Tree: Count Leaves
Euler: Count Odd-Degree Vertices
Euler: Circuit / Path / None
BFS: Number of Reachable Vertices
BFS: Shortest Unweighted Distance
BFS: Bipartite Check
DFS: Count Connected Components
DFS: Does a Path Exist
DFS: Detect Cycle (Directed)
Graph: Build the Adjacency Matrix
Graph: Maximum In/Out Degree Difference
Hash Table: Bucket Sizes
Hash Table: Longest Chain
Heap: Insert (sift-up)
Heap: Delete-max (sift-down)
Heap: k-th Largest
Linked List: Build and Print
Linked List: Recursive Sum
MST: Total Weight
MST: Largest Edge in the MST
Queue: Simulate Dequeue Order
Queue: Final Contents
Recursion: Factorial
Recursion: Tower of Hanoi
Recursion: Subset Sum
Sorting: Ascending Order
Sorting: Stable Sort by Key
Sorting: Count Inversions
Stack: Balanced Brackets
Stack: Decimal to Binary
Tree Traversal: Pre / In / Post-order
Tree Traversal: Level Order (BFS)
Trie: count stored words
Trie: is it a stored word
2-3-4 Node: which child
2-3-4 Tree: root after insertions
Binary Search: Index of Target
Stack ADT: PUSH / POP
Stable Sort by Score
Priority Queue: insert / extract-max
Dijkstra: Shortest Distances from 0
Topological Order (lexicographically smallest)