C-CAT Data Structures Revision: Topic-wise Guide

revision Published 9 min read

Data structures for C-CAT

Data structures questions in Section B are short and conceptual: which structure fits a situation, what an operation costs, what a traversal prints, or what a snippet does to a list. This guide organises the revision by topic and lists the facts you should be able to recall without thinking.


Topic checklist

TopicBe able to
ComplexityRead Big-O for loops and recursion; know best, average and worst cases
ArraysCompute address of an element; insertion and deletion cost
Linked listsSingly, doubly, circular; insert, delete, reverse
StacksLIFO, push and pop, infix to postfix, postfix evaluation
QueuesFIFO, circular queue, deque, priority queue
TreesTerminology, traversals, binary search tree operations
HeapsMin-heap and max-heap, heapify, build-heap cost
GraphsAdjacency matrix vs list, BFS, DFS
Searching and sortingCompare algorithms by time, space and stability
HashingHash functions, collisions, chaining and open addressing

Complexity at a glance

OperationTypical cost
Access array element by indexO(1)
Insert at the beginning of an arrayO(n)
Insert at the head of a linked listO(1)
Search in an unsorted listO(n)
Binary search on a sorted arrayO(log n)
BST search, balancedO(log n)
BST search, skewedO(n)
Push, pop on a stackO(1)
Enqueue, dequeueO(1)
Build a heapO(n)

Rule of thumb: a loop that halves the problem each time is O(log n); nested loops over the same input are O(n^2).


Linked lists

  • A singly linked list gives O(1) insertion at the head but O(n) at the tail unless a tail pointer is kept.
  • Reversing a list means changing the next pointers, using three pointers: previous, current and next.
  • Deleting a node from a singly linked list needs access to the previous node.
  • A doubly linked list stores two pointers per node, so it uses more memory but lets you traverse both ways.
  • Detecting a cycle is done with two pointers moving at different speeds.

Stacks and queues

  • A stack is LIFO. Uses: function calls, undo, expression evaluation, balanced bracket checks.
  • A queue is FIFO. Uses: scheduling, buffering, BFS.
  • In a circular queue of size n, the queue is full when (rear + 1) % n == front.
  • A priority queue serves the element with the highest priority first, and is usually built on a heap.
  • Infix to postfix: operands go straight out; operators wait on a stack; pop operators of higher or equal precedence before pushing a new one. ^ is right-associative, so it is handled differently.
  • Postfix evaluation: scan left to right, push operands, and on an operator pop two values (the first popped is the right operand), apply it and push the result.

Trees

  • Traversals of a binary tree: inorder (left, root, right), preorder (root, left, right), postorder (left, right, root).
  • Inorder traversal of a binary search tree gives sorted order.
  • A binary tree with n nodes has n - 1 edges.
  • The maximum number of nodes at level l (root at level 0) is 2^l, and a tree of height h has at most 2^(h+1) - 1 nodes.
  • A tree can be rebuilt from inorder plus either preorder or postorder, but not from preorder plus postorder alone in general.
  • AVL trees keep the balance factor of every node between -1 and 1 using rotations, so search stays O(log n).
  • A heap is a complete binary tree, which is why it can be stored in an array: the children of index i are at 2i + 1 and 2i + 2.

Graphs

  • An adjacency matrix uses O(V^2) space and checks an edge in O(1). An adjacency list uses O(V + E) space and suits sparse graphs.
  • BFS uses a queue and finds the shortest path in an unweighted graph.
  • DFS uses a stack or recursion and is used for cycle detection and topological sorting.
  • A graph with V vertices that is a tree has exactly V - 1 edges.

Sorting and searching

AlgorithmBestAverageWorstStable
Bubble sortO(n)O(n^2)O(n^2)Yes
Insertion sortO(n)O(n^2)O(n^2)Yes
Selection sortO(n^2)O(n^2)O(n^2)No
Merge sortO(n log n)O(n log n)O(n log n)Yes
Quick sortO(n log n)O(n log n)O(n^2)No
Heap sortO(n log n)O(n log n)O(n log n)No

Binary search needs a sorted array and runs in O(log n). Linear search works on any list in O(n).


Hashing

  • A good hash function spreads keys evenly and is fast to compute.
  • Chaining keeps colliding keys in a list at the same slot. Open addressing probes for another free slot (linear probing, quadratic probing, double hashing).
  • The load factor is the number of stored keys divided by the table size; performance drops as it approaches 1.

Revise and practise


Key takeaways

  • Learn the complexity table; many questions are only about cost.
  • Trees and stacks produce the most questions, so give them the most time.
  • Practise traversals and infix to postfix on paper.
  • Know which sorting algorithms are stable and what their worst case is.

Frequently Asked Questions

1 Which data structures topics matter most for C-CAT?

Stacks, queues, linked lists, binary trees and traversals, binary search trees, sorting and searching, and time complexity are the core. Graph basics such as BFS and DFS are worth knowing too.

2 Do I need to write code for data structures in C-CAT?

C-CAT is an MCQ exam, so you are more likely to trace a short snippet or pick the correct complexity than write a full program. Understanding how each operation works is what matters.

3 What is the time complexity to remember for sorting?

Bubble, insertion and selection sort are O(n^2) in the worst case. Merge sort is O(n log n) always. Quick sort is O(n log n) on average and O(n^2) in the worst case. Heap sort is O(n log n).

4 How do I convert infix to postfix quickly?

Scan left to right, send operands straight to the output, and use a stack for operators, popping operators of higher or equal precedence before pushing a new one. Practise this on paper until it is automatic.

5 How many days should I give data structures?

A focused revision takes about 4 to 6 days if you already know the basics. Spend most of the time on trees, stacks and complexity, because they produce the most questions.