Two-credit paper dominated by traces: draw the structure after every operation and write the final contents or complexity, not a prose description.
1. Introduction and Arrays
Recall anchor. Contiguous memory buys O(1) access and costs O(n) shifts: that single trade-off explains most array questions.
Scored points.
- Data structure definition: a way of organising data for efficient access and modification; need — speed, memory, and clarity.
- Classification: linear (array, stack, queue, list) vs non-linear (tree, graph); static (fixed size, array) vs dynamic (linked list).
- Algorithm efficiency — Big O concept only: O(1) constant array access, O(n) linear scan, O(log n) binary search, O(n²) nested loops.
- Array operations: insert shifts elements right, delete shifts left, search checks positions, traverse visits each index once; index runs 0 to n−1.
- 2D array: A[i][j] in row-major order; matrix addition adds matching entries, transpose sets B[j][i] = A[i][j].
- Real connect: NumPy arrays, images as 2D matrices, sensor logs, and spreadsheet rows are all arrays.
- Practice tasks: trace insertion at index 2, deletion of 30, count even/odd, find max–min–average, remove duplicates.
Formula strip.
Micro-example. Insert 25 at index 2 of [10,20,30,40]: shift 30 and 40 right → [10,20,25,30,40]; deleting 30 from [10,20,30,40] gives [10,20,40].
Examiner line. Show the index positions before and after the operation, then write the complexity; the trace and the Big O are separate marks.
2. Linked List
Recall anchor. Rewire the pointer, don't shift the data: every insertion or deletion is a two-pointer assignment in a fixed order.
Scored points.
- Node = data + pointer(next); the head pointer locates the first node and NULL marks the end.
- Why linked list over array: dynamic size and O(1) insertion at head, but no direct indexing and extra pointer memory.
- Singly linked list insert at head: new->next = head; head = new. Insert at tail walks to the last node; insert at position k stops at node k−1.
- Deletion: locate the previous node, set prev->next = cur->next, then free cur; deleting the head updates head itself.
- Traversal: start at head and follow next until NULL; count nodes with a running counter.
- Doubly linked list has prev and next pointers, enabling backward movement; circular linked list has tail->next = head.
- Real connect: browser back/forward uses a doubly linked list, a music playlist is circular, and Python deque supports BFS and LRU caches.
Formula strip.
Micro-example. Inserting 10, 20, 30 at the head gives 30 → 20 → 10 → NULL; deleting node 20 leaves 30 → 10 → NULL.
Examiner line. Draw the list with arrows after each pointer assignment; state which pointer changes first and why reversing the order would lose the list.
3. Stack and Queue
Recall anchor. Stack = LIFO at top, Queue = FIFO from front to rear: the application decides which structure, the trace decides which mark.
Scored points.
- Stack operations: push adds at top, pop removes from top, peek reads top without removing; array implementation uses an index top initialised to −1.
- Stack applications: balanced-parentheses check (push opening bracket, pop on a matching closing bracket, balanced iff stack is empty at the end), function call stack, and undo (Ctrl+Z).
- Queue operations: enqueue adds at rear, dequeue removes from front; array implementation with front and rear indices must handle wrap-around in a circular queue.
- Queue applications: print spooler, task scheduling, WhatsApp delivery queue, and CPU scheduling.
- Polish notation: prefix operators precede operands; scanf/postfix conversion uses a stack of operands.
- Tracing convention: write the stack bottom-to-top and the queue front-to-rear after every operation.
- Python traceback is a visible call stack; both structures can be shown with array or linked implementation in C/Python.
Formula strip.
Micro-example. push(5), push(10), pop() returns 10, push(15) → top = 15 with stack [5, 15]; enqueue(A), enqueue(B), dequeue() → A, enqueue(C) → front = B.
Examiner line. For a bracket or call-stack question, show the stack contents at each bracket or call; conclude with one explicit yes/no or final top value.
4. Searching and Sorting
Recall anchor. Search needs order for binary; sorting buys that order: compare the number of comparisons, not just the final list.
Scored points.
- Linear search scans index 0…n−1 until a match; O(n) worst case and works on unsorted data.
- Binary search requires a sorted array: mid = ⌊(low+high)/2⌋; discard the half that cannot contain the key; O(log n).
- Bubble sort repeatedly swaps adjacent out-of-order pairs; n−1 passes, O(n²), and early exit if a pass has no swaps.
- Insertion sort grows a sorted prefix by inserting the next element at its correct place; O(n²) worst case, efficient for nearly sorted data.
- Selection sort picks the minimum of the unsorted suffix and swaps it into place; O(n²) with at most n−1 swaps.
- Quick sort partitions around a pivot and recurses on the two sides; merge sort divides, sorts, and merges in O(n log n) with extra memory.
- Python built-ins: sort() sorts in place, sorted() returns a new list, both use Timsort (merge + insertion hybrid); applications include database indexes, leaderboards, and ML preprocessing.
Formula strip.
Micro-example. Binary search for 35 in [10,20,30,35,40,50]: mid = 30 → go right; mid = 40 → go left; mid = 35 → found in 3 comparisons, versus 4 for linear search.
Examiner line. Show each comparison and the retained half for binary search, or each pass for a sort; then state the complexity and stability in the last line.
5. Trees and Graphs (Concept Level)
Recall anchor. BST order gives sorted inorder; graph representation decides traversal cost: draw the small tree or graph before answering.
Scored points.
- Binary tree terminology: root, child, leaf, level, height; a binary tree of height h has at most 2^{h+1}−1 nodes and 2^h leaves at the last level.
- Binary Search Tree property: left subtree values < node < right subtree values; insert by comparison, search by the same comparison.
- Traversals: inorder (left, root, right) of a BST gives sorted order; preorder (root, left, right) copies the tree structure; postorder (left, right, root) is used for deletion.
- Graph basics: vertex, edge, directed/undirected, weighted/unweighted; adjacency list stores only existing edges, saving space for sparse graphs.
- Insertion into an adjacency list adds a neighbour to the vertex's list; undirected graphs add the reverse edge too.
- BFS uses a queue and visits level by level; DFS uses a stack (or recursion) and goes deep first; trace both on a 5–6 node graph.
- Real connect: file system = tree, database indexing = BST, maps = weighted graph, social network = graph, decision tree in ML = binary tree.
Formula strip.
Micro-example. Inserting 50, 30, 70, 20, 40 into a BST: inorder = 20, 30, 40, 50, 70; preorder = 50, 30, 20, 40, 70; a BFS from A on A–B, A–C, B–D, C–E visits A, B, C, D, E.
Examiner line. Draw the tree/graph, label root and leaves, then write the traversal order as a comma-separated list; a trace without the drawing loses the structure marks.
Memory map
%%{init: {'theme': 'base', 'look': 'handDrawn', 'themeVariables': {'fontFamily': "'Nunito', sans-serif", 'fontSize': '15px', 'primaryColor': '#EFEAD6', 'primaryBorderColor': '#0F766E', 'lineColor': '#23211C'}}}%%
flowchart LR
A["U1: Array — insert, delete, search, traverse"] --> B["U1: 2D array — matrix addition and transpose"]
B --> C["U2: Node — data + pointer"] --> D["U2: Singly linked list — insert, delete, traverse"]
D --> E["U2: Doubly linked list"] --> F["U3: Stack — LIFO, push, pop, peek"]
F --> G["U3: Application: balanced parentheses check"] --> H["U3: Queue — FIFO, enqueue, dequeue"]
H --> I["U4: Linear search"] --> J["U4: binary search"]
J --> K["U4: Bubble sort and insertion sort"] --> L["U4: Quick Sort and Selection Sort"]
L --> M["U5: Binary Search Tree — insert, search"] --> N["U5: inorder/preorder traversal trace"]
N --> O["U5: adjacency list representation"] --> P["U5: BFS and DFS — trace on a small graph"]
Rapid recall
- U1 · Data structure — definition, need, classification
- U1 · Algorithm efficiency — Big O notation
- U1 · Array — insert, delete, search, traverse in C/Python
- U1 · 2D array — matrix addition and transpose
- U1 · NumPy array (AI/ML)
- U2 · Node — data + pointer
- U2 · why linked list over array
- U2 · Singly linked list — insert (head, tail, position), delete, traverse
- U2 · Doubly linked list — concept and structure
- U2 · Circular linked list — concept
- U3 · Stack — LIFO, push, pop, peek
- U3 · implementation using array in C/Python
- U3 · Application: balanced parentheses check
- U3 · function call stack
- U3 · Queue — FIFO, enqueue, dequeue
- U3 · Application: print spooler
- U3 · task scheduling queue
- U3 · Polish Notation
- U4 · Linear search
- U4 · binary search
- U4 · comparison of searching
- U4 · Bubble sort and insertion sort
- U4 · Quick Sort and Selection Sort — trace
- U4 · Merge sort — concept and trace
- U4 · Python built-in sort() and sorted()
- U5 · Binary tree — terminology and properties
- U5 · Binary Search Tree — insert, search
- U5 · inorder/preorder traversal trace
- U5 · Graph — vertex, edge, directed/undirected
- U5 · adjacency list representation
- U5 · BFS and DFS — trace on a small graph
- U5 · Decision Tree in ML = binary tree
Final-answer checklist
- For ACS201, draw the array, node chain, stack, sorted list, or tree before writing the answer.
- Show the state after each operation; the examiner awards step marks on intermediate traces.
- State the complexity with the correct operation attached (access, search, insertion, or sort), not as an isolated buzzword.
- For BST and graph questions, give inorder/preorder or BFS/DFS as an explicit comma-separated sequence.
- End with the requested final value: top element, front element, sorted array, or traversal order.