Data Structures & Algorithms (DSA) High-Yield Checklist
Data Structures and Algorithms (DSA) accounts for 10% of the NSCT, but its principles permeate the entire examination. Questions test your ability to select optimal data structures under asymptotic time and space tradeoffs.
Use this checklist to ensure complete coverage of tested topics.
1. Asymptotic Analysis & Big-O Quick Sheet
Always know both average-case and worst-case complexities:
| Data Structure / Algorithm | Access / Search | Insertion | Deletion | Space Complexity |
|---|---|---|---|---|
| Array (Dynamic) | $O(1)$ / $O(n)$ | $O(n)$ (amortized $O(1)$) | $O(n)$ | $O(n)$ |
| Singly Linked List | $O(n)$ | $O(1)$ at head, $O(n)$ at tail | $O(1)$ at head, $O(n)$ at tail | $O(n)$ |
| Hash Table | $O(1)$ avg / $O(n)$ worst | $O(1)$ avg / $O(n)$ worst | $O(1)$ avg / $O(n)$ worst | $O(n)$ |
| Binary Search Tree (Unbalanced) | $O(h) | |||
| ightarrow O(n)$ | $O(h) | |||
| ightarrow O(n)$ | $O(h) | |||
| ightarrow O(n)$ | $O(n)$ | |||
| AVL / Red-Black Tree | $O(\log n)$ | $O(\log n)$ | $O(\log n)$ | $O(n)$ |
| Binary Heap (Priority Queue) | Find Min: $O(1)$ | Insert: $O(\log n)$ | Extract Min: $O(\log n)$ | $O(n)$ |
Sorting Complexity Recap
- Quick Sort: Average $O(n \log n)$, Worst $O(n^2)$ when pivot is poorly chosen (e.g., sorted array with first element as pivot). Not stable by default.
- Merge Sort: Guaranteed $O(n \log n)$ time, requires $O(n)$ auxiliary space. Stable.
- Heap Sort: Guaranteed $O(n \log n)$ time, $O(1)$ space. Unstable.
- Counting / Radix Sort: $O(n + k)$ non-comparison based linear sorting.
2. Trees and Binary Search Trees (BST)
- In-order Traversal of BST: Always yields elements in strictly ascending order.
- Tree Height vs Node Count: For a balanced tree with $n$ nodes, minimum height is $\lfloor \log_2 n floor$. For a degenerate tree (skewed linked list), height is $n - 1$.
- Full vs Complete vs Perfect Binary Tree:
- Full: Every node has 0 or 2 children.
- Complete: All levels completely filled except possibly the last, which is filled from left to right.
- Perfect: All internal nodes have 2 children and all leaves are at the exact same level.
3. Graph Algorithms & Traversals
- Breadth-First Search (BFS): Uses a
Queue. Finds shortest path in unweighted graphs. Time: $O(V + E)$. - Depth-First Search (DFS): Uses a
Stack(or recursion call stack). Used for cycle detection, topological sorting, and connected components. Time: $O(V + E)$. - Dijkstra’s Algorithm: Shortest path in weighted graph with non-negative edge weights using Min-Heap: $O((V + E) \log V)$. Fails with negative edges.
- Bellman-Ford Algorithm: Handles negative weights and detects negative weight cycles. Time: $O(V \cdot E)$.
- Minimum Spanning Tree (MST):
- Kruskal’s Algorithm: Sorts edges, uses Disjoint-Set Union (DSU). $O(E \log E)$.
- Prim’s Algorithm: Grows MST from a vertex using Min-Heap. $O(E \log V)$.
4. Dynamic Programming (DP) Core Archetypes
NSCT does not expect you to write 50 lines of DP code from scratch; rather, it asks for recurrence relations, state definitions, and memoization table dimensions:
- 0/1 Knapsack: State
dp[i][w], time $O(n \cdot W)$, space $O(n \cdot W)$ or $O(W)$ optimized. - Longest Common Subsequence (LCS): If $A[i] == B[j]$,
dp[i][j] = 1 + dp[i-1][j-1], elsemax(dp[i-1][j], dp[i][j-1]). - Coin Change: Unbounded knapsack recurrence.
Practice Strategy
Solve all 238 DSA MCQs available on NSCTPrep. Focus especially on identifying when a hash table trades space for $O(1)$ lookup over an $O(n \log n)$ binary search.
Content structured in accordance with Higher Education Commission (HEC) Computing National Curriculum, PSEB TechLift competency standards, and the 120-minute Virtual University assessment model.