Download .md

CMS 702: Syllabus Topics NOT in My Handwritten Notes

These topics appear on the official course outline (the course outline) but are missing or only named in the class notes. Standard textbook material, kept short and exam-shaped. Source: standard DSA material, not the lecturer's notes: the wording in my notes always wins if they differ.


1. Graphs & Their Representation ← biggest gap

A graph G = (V, E) is a non-linear data structure consisting of a set of vertices (nodes) V and a set of edges E connecting pairs of vertices.

Types

Two standard representations

Adjacency Matrix Adjacency List
Structure V×V matrix, M[i][j] = 1 if edge i→j Array of V lists; each list holds a vertex's neighbours
Space O(V²) O(V + E)
Check edge (u,v) O(1) O(degree of u)
List all neighbours O(V) O(degree)
Best for Dense graphs Sparse graphs

Example, undirected graph with vertices A,B,C and edges AB, BC:

Adjacency Matrix        Adjacency List
    A  B  C             A → B
A [ 0  1  0 ]           B → A, C
B [ 1  0  1 ]           C → B
C [ 0  1  0 ]

Graph traversals

Note the link to my notes: BFS = queue = FIFO; DFS = stack = LIFO.


2. Sorting Algorithm Mechanics

Your notes name five sorts but don't give mechanics or complexity. Learn this table.

Algorithm How it works Best Average Worst Space Stable
Bubble Repeatedly swap adjacent out-of-order pairs O(n) O(n²) O(n²) O(1) Yes
Selection Repeatedly pick the minimum and place it at the front O(n²) O(n²) O(n²) O(1) No
Insertion Insert each element into its place in the sorted prefix O(n) O(n²) O(n²) O(1) Yes
Merge Divide list in half, sort each half, merge them O(n log n) O(n log n) O(n log n) O(n) Yes
Quick Pick a pivot, partition around it, recurse on each side O(n log n) O(n log n) O(n²) O(log n) No
Heap Build a max-heap, repeatedly extract the max O(n log n) O(n log n) O(n log n) O(1) No
Counting Count occurrences of each key, rebuild in order O(n+k) O(n+k) O(n+k) O(k) Yes
Bucket Scatter into buckets, sort each bucket, concatenate O(n+k) O(n+k) O(n²) O(n) Yes

Merge sort is divide-and-conquer; quick sort is also divide-and-conquer but its worst case O(n²) occurs when the pivot is always the smallest/largest element (e.g. already-sorted input with a first-element pivot).

Counting and bucket sort are not comparison sorts: this is how they beat the O(n log n) comparison lower bound.


Sequential Search Binary Search
Requires sorted data No Yes
Method Check each element from first to last Compare with middle, discard half, repeat
Best case O(1) O(1)
Worst case O(n) O(log n)
Works on Arrays, linked lists Arrays (needs random access)

4. Time–Space Tradeoff

Named on the outline; state it as: an algorithm can often be made faster by using more memory, or made to use less memory at the cost of running longer.

Examples to cite:


5. Recursive Algorithms

A recursive algorithm solves a problem by calling itself on smaller sub-problems.

Every recursion needs:

  1. A base case: the condition that stops the recursion.
  2. A recursive case: the call on a smaller input, moving toward the base case.
factorial(n):
    if n <= 1:  return 1        # base case
    else:       return n * factorial(n - 1)   # recursive case

6. Stack Allocation vs Heap Allocation (Run-time Storage Management)

Stack Heap
What lives there Local variables, function parameters, return addresses Dynamically allocated objects
Allocated by Compiler, automatically on function call Programmer at run time (malloc/new)
Freed by Automatically on function return Programmer (free/delete) or garbage collector
Size Fixed, small Large, grows at run time
Speed Very fast (move stack pointer) Slower (search for a free block)
Order LIFO Any order
Failure mode Stack overflow Memory leak / fragmentation

Run-time storage management is the system's job of allocating memory as a program runs and reclaiming it afterwards, via the stack for call frames, the heap for dynamic data, plus garbage collection (automatic reclamation of unreachable objects) or manual deallocation.

Don't confuse: the stack (memory region) with the stack ADT (LIFO data structure), and the heap (memory region) with the heap data structure (the tree used by heap sort). Exam questions like to test this.


7. Strings and String Processing


8. Records / Structures

A record (struct) is a composite data type grouping fields of possibly different types under one name, e.g. a Student record with name (string), matric_no (int), cgpa (float). Contrast with an array, which holds many elements of the same type. Records are the building block of a node (data field + pointer field).


9. Numerical Algorithms

Algorithms operating on numeric data, where precision and error matter as much as speed. Examples worth naming:

Key issue to mention: floating-point round-off error accumulates, so numerical algorithms are judged on numerical stability, not just complexity.