Top Banner Ad

BCS301 — DATA STRUCTURE

1-page visual cheat sheets and Mermaid memory maps for rapid revision.

VISUAL MEMORY MAP & CHEAT SHEET

Full 5-unit Mermaid mind map, recall anchors, and formula strips rendered below.

Save as PNG / Print →

Five units in exam order: array/list representation and complexity, stacks and queues, searching/sorting/hashing, trees, graphs. Each unit carries its own formula strip; do not borrow one unit's relation in another.

1. Introduction

Recall anchor. Basic Terminology and Asymptotic notations: Big Oh: the structure is chosen by matching access pattern to operation count—arrays give O(1) indexed access, linked lists give O(1) insertion at a known node, and Big-Oh bounds the growth of the algorithm.

Scored points.

  • Basic Terminology separates what is stored from the operations defined on it: insert, delete, search, traverse and modify.
  • Efficiency of an Algorithm and Time and Space Complexity count elementary operations and extra memory as functions of input size n; the worst case gives a guarantee.
  • Asymptotic notations: Big Oh gives an upper bound, Big Theta a tight bound and Big Omega a lower bound; the ladder is O(1), O(log n), O(n), O(n²).
  • Single and Multidimensional Arrays with Representation of Arrays: Row Major Order and Column Major Order fix how a 2-D or 3-D element is linearised before the index formula is derived.
  • Sparse Matrices and their representations store only non-zero entries, cutting memory from O(rows×cols) to O(nonzeros) with triplet or linked forms.
  • Linked lists: Array Implementation and Pointer Implementation of Singly Linked Lists, Doubly Linked List and Circularly Linked List support dynamic size; Insertion, Deletion and Traversal update links.
  • Polynomial Representation and Addition Subtraction & Multiplications of Single variable & Two variables Polynomial keeps terms ordered by exponent so like powers combine in one pass.

Formula strip.

Loc(A[i])=B+i⋅s,Locrow(A[i][j])=B+[i⋅N+j]⋅s,Loccol(A[i][j])=B+[j⋅M+i]⋅s\text{Loc}(A[i])=B+i\cdot s,\quad \text{Loc}_{row}(A[i][j])=B+[i\cdot N+j]\cdot s,\quad \text{Loc}_{col}(A[i][j])=B+[j\cdot M+i]\cdot s

Micro-example. With B=1000, s=4 bytes, M=3 rows and N=4 columns, A[2][3] in row-major lies at 1000+(2×4+3)×4 = 1060.

Examiner line. For Introduction, name the storage representation first, derive the address from base and index, then close with the complexity of the stated operation.

2. Stacks

Recall anchor. Primitive Stack operations: Push & Pop and Application of stack: Prefix and Postfix Expressions: LIFO order makes push/pop O(1) at the top, which is exactly what recursion unwinding and postfix evaluation require.

Scored points.

  • Abstract Data Type states push, pop, peek, isFull and isEmpty without committing to an array or linked implementation.
  • Array and Linked Implementation of Stack in C: the array version uses a top index and fixed capacity; the linked version allocates a node per push and grows until memory ends.
  • Evaluation of postfix expression scans left to right, pushes operands, and applies each operator to the top two operands at once; no precedence table is needed.
  • Iteration and Recursion—Principles of recursion and Tail recursion: every call adds an activation record; a tail call can be replaced by a loop that updates parameters and returns once.
  • Removal of recursion with examples such as binary search, Fibonacci numbers and Hanoi towers: binary search halves the range, naive Fibonacci repeats subproblems, Hanoi needs 2ⁿ−1 moves.
  • Queues: Operations on Queue—Create, Add, Delete, Full and Empty—track front and rear; Circular queues wrap rear to zero so a full queue is not reported as full early.
  • Dequeue and Priority Queue allow both-end operations or priority-based removal; Array and linked implementation of queues in C trades fixed capacity against dynamic nodes.

Formula strip.

push:top←top+1, S[top]←x;pop:x←S[top], top←top−1;MHanoi(n)=2n−1\text{push}: top\leftarrow top+1,\ S[top]\leftarrow x;\qquad \text{pop}: x\leftarrow S[top],\ top\leftarrow top-1;\qquad M_{Hanoi}(n)=2^n-1

Micro-example. Postfix 2 3 + 4 * → push 2, push 3, + gives 5, push 4, * gives 20; the same infix (2+3)×4 needs parentheses.

Examiner line. For Stacks, show the top-of-stack state after every operation, then name the application—postfix, recursion or queue variant—that consumes that state.

3. Searching

Recall anchor. Concept of Searching, Sequential search and Binary Search: linear search scans n keys, binary search halves a sorted list per comparison, and hashing aims for direct access with a collision rule.

Scored points.

  • Concept of Searching and Sequential search compare keys one by one; the successful average is (n+1)/2 comparisons and the worst case is n.
  • Index Sequential Search keeps an index of block maxima: locate the block first, then scan inside it, reducing work to roughly √n order.
  • Binary Search requires a sorted array, computes mid=(low+high)/2 and discards half the range; the worst comparison count is ⌊log₂n⌋+1.
  • Concept of Hashing & Collision resolution Techniques used in Hashing map a key to a bucket with h(k)=k mod m; linear probing, quadratic probing, chaining and rehashing repair collisions.
  • Sorting: Insertion Sort, Selection and Bubble Sort are O(n²); insertion builds a sorted prefix, selection picks the minimum, bubble swaps adjacent out-of-order pairs.
  • Quick Sort partitions around a pivot (O(n log n) average, O(n²) worst); Merge Sort splits and merges in O(n log n) using O(n) extra space.
  • Heap Sort and Radix Sort: heap sort repeatedly extracts the heap root in O(n log n) in place; radix sort processes digits with counting sort in O(d(n+b)).

Formula strip.

mid=⌊low+high2⌋,Cbinmax=⌊log⁡2n⌋+1,h(k)=k mod m,hi(k)=(h(k)+i) mod mmid=\left\lfloor\frac{low+high}{2}\right\rfloor,\quad C_{bin}^{max}=\lfloor\log_2 n\rfloor+1,\quad h(k)=k\bmod m,\quad h_i(k)=(h(k)+i)\bmod m

Micro-example. With m=11, h(27)=27 mod 11=5; if bucket 5 is occupied, linear probing tries 6, then 7, until a free slot is found.

Examiner line. A Searching answer must say whether the input is sorted, quote the comparison count, and name the collision rule or pivot before writing the trace.

4. Trees

Recall anchor. Binary Search Tree and Tree Traversal algorithms: Inorder, Preorder and Postorder: the left-subtree < node < right-subtree rule makes search O(h), while the traversal order decides what the examiner reads from the same tree.

Scored points.

  • Basic terminology used with Tree: root, parent, child, leaf, depth and height; a binary tree allows at most two children per node.
  • Binary Tree Representation: Array Representation stores a node's children at 2i+1 and 2i+2; Pointer(Linked List) Representation stores explicit left and right links.
  • Strictly Binary Tree has zero or two children; Complete Binary Tree fills levels left to right; A Extended Binary Trees add external null nodes.
  • Tree Traversal algorithms: Inorder (LNR) yields sorted BST order, Preorder (NLR) a prefix form, Postorder (LRN) a postfix form; Constructing Binary Tree from given Tree Traversal needs inorder plus preorder or postorder.
  • Operation of Insertation, Deletion, Searching & Modification of data in Binary Search: insert at a leaf, delete a two-child node via its inorder successor or predecessor.
  • Threaded Binary trees and Traversing Threaded Binary trees replace null links with traversal threads so no explicit stack is needed.
  • Huffman coding using Binary Tree merges the two lowest weights; Concept & Basic Operations for AVL Tree applies LL/RR/LR/RL rotations to restore |BF|≤1; B Tree & Binary Heaps maintain multiway search order and heap order.

Formula strip.

Nmax(h)=2h+1−1,h=⌊log⁡2n⌋,BF=hL−hR∈{−1,0,1},WPL=∑ifiliN_{max}(h)=2^{h+1}-1,\quad h=\lfloor\log_2 n\rfloor,\quad BF=h_L-h_R\in\{-1,0,1\},\quad WPL=\sum_i f_i l_i

Micro-example. A complete binary tree of height 3 holds at most 2⁴−1 = 15 nodes; Huffman weights 2, 3, 5 give WPL = (2+3)×2 + 5×1 = 15.

Examiner line. For Trees, draw the tree or rotation, write the traversal sequence explicitly, and tie the height you used to the search or insertion cost reported.

5. Graphs

Recall anchor. Data Structure for Graph Representations: Adjacency Matrices, Adjacency List and Minimum Cost Spanning Trees: Prims and Kruskal algorithm: representation fixes traversal cost O(V²) versus O(V+E), and an MST grows V−1 acyclic edges of minimum total weight.

Scored points.

  • Terminology used with Graph: vertex, edge, degree, path, cycle and connectedness; the handshaking lemma gives Σdeg = 2E.
  • Data Structure for Graph Representations: Adjacency Matrices use an n×n matrix with O(1) edge test; Adjacency List stores only existing edges and saves space on sparse graphs.
  • Graph Traversal: Depth First Search and Breadth First Search: DFS uses a stack/recursion and goes deep first; BFS uses a queue and gives fewest-edge paths in an unweighted graph.
  • Connected Component: one DFS/BFS from an unvisited vertex enumerates one component; repeating over all vertices counts the components.
  • Spanning Trees contain all V vertices and V−1 edges without a cycle; Minimum Cost Spanning Trees: Prims and Kruskal algorithm grow from a vertex or from sorted edges respectively.
  • Transitive Closure and Shortest Path algorithm: Warshal Algorithm builds reachability by dynamic programming; Dijikstra Algorithm relaxes tentative distances and needs non-negative weights.
  • Adjacency queries must distinguish directed from undirected graphs before in-degree and out-degree are counted.

Formula strip.

Smatrix=O(V2),Slist=Θ(V+E),∣E∣MST=V−1,TWarshall=O(V3),TDijkstra=O((V+E)log⁡V)S_{matrix}=O(V^2),\quad S_{list}=\Theta(V+E),\quad |E|_{MST}=V-1,\quad T_{Warshall}=O(V^3),\quad T_{Dijkstra}=O((V+E)\log V)

Micro-example. A connected graph with 5 vertices has exactly 4 edges in every spanning tree; BFS from vertex 1 reaches all 5 vertices in at most 4 edge steps.

Examiner line. In a Graphs answer, state the representation, trace the traversal order or the chosen MST edges, and finish with the complexity that follows from that representation.

Memory map

%%{init: {'theme': 'base', 'look': 'handDrawn', 'themeVariables': {'fontFamily': "'Nunito', sans-serif", 'fontSize': '17px', 'primaryColor': '#EFEAD6', 'primaryBorderColor': '#0F766E', 'lineColor': '#23211C'}}}%%
flowchart LR
  U1["Introduction"] --> U1a["Time and Space Complexity"] --> U1b["Sparse Matrices and their representations"]
  U1b --> U2["Stacks"] --> U2a["Primitive Stack operations: Push & Pop"] --> U2b["Evaluation of postfix expression"]
  U2b --> U3["Searching"] --> U3a["Binary Search"] --> U3b["Concept of Hashing & Collision resolution Techniques used in Hashing"]
  U3b --> U4["Trees"] --> U4a["Tree Traversal algorithms: Inorder"] --> U4b["Concept & Basic Operations for AVL Tree"]
  U4b --> U5["Graphs"] --> U5a["Graph Traversal: Depth First Search and Breadth First Search"] --> U5b["Minimum Cost Spanning Trees: Prims and Kruskal algorithm"]

Rapid recall

  1. U1 Introduction — Basic Terminology; Elementary Data Organization; Built in Data Types in C. Algorithm; Efficiency of an Algorithm; Time and Space Complexity; Big Oh, Big Theta and Big Omega; Derivation of Index Formulae for 1-D and 2-D; Sparse Matrices and their representations; Polynomial Representation and Addition Subtraction & Multiplications.
  2. U2 Stacks — Abstract Data Type; Primitive Stack operations: Push & Pop; Array and Linked Implementation of Stack in C; Prefix and Postfix Expressions; Evaluation of postfix expression; Principles of recursion; Tail recursion; Fibonacci numbers; Hanoi towers; Circular queues; Dequeue and Priority Queue.
  3. U3 Searching — Concept of Searching; Sequential search; Index Sequential Search; Binary Search; Concept of Hashing & Collision resolution Techniques used in Hashing; Insertion Sort; Selection; Bubble Sort; Quick Sort; Merge Sort; Heap Sort and Radix Sort.
  4. U4 Trees — Basic terminology used with Tree; Binary Trees; Array Representation and Pointer(Linked List) Representation; Binary Search Tree; Strictly Binary Tree; Complete Binary Tree; Inorder, Preorder and Postorder; Constructing Binary Tree from given Tree Traversal; Threaded Binary trees; Huffman coding using Binary Tree; AVL Tree; B Tree & Binary Heaps.
  5. U5 Graphs — Terminology used with Graph; Adjacency Matrices; Adjacency List; Depth First Search and Breadth First Search; Connected Component; Spanning Trees; Prims and Kruskal algorithm; Warshal Algorithm and Dijikstra Algorithm.

Final-answer checklist (BCS301)

  • Name the representation—row/column major, linked list, BST rotation, adjacency matrix/list—before applying its index or complexity relation.
  • State sortedness before Binary Search and non-negative weights before Dijkstra; write the exact traversal order (Inorder/Preorder/Postorder) used.
  • For recursion, give the recurrence or activation-record count; for hashing, name the collision rule actually applied.
  • Show one numeric address, comparison count, height, balance factor or edge count with the derived formula visible.
  • Close with the asked result—bucket index, tree sequence, MST edge set or complexity—in one explicit sentence.
Bottom Banner Ad