Programming & Data Structures
The programming spine of a first-year M.Tech AI semester: Python values, control flow, collections, functions, objects, exceptions and files — then the classic data structures (arrays, stacks, queues, linked lists, trees, heaps, hash tables, graphs) and the algorithms that operate on them (asymptotic analysis, sorting, searching, traversal, string matching). Intuition first, an artifact you can play with, then the code and the cost.
Python foundations
Values, variables, input/output and operators; booleans, conditionals and loops; the core containers (list, tuple, set, dict); and functions with arguments, return values and scope.
- First programs: values, names and operatorsStatements evaluate expressions into values, names bind to values, and every operator has a type it works on. 10 min · intro
- Control flow: booleans, branches and loopsTruth values, if/elif/else, and the two loop forms that decide how many times a block runs. 11 min · intro
- Collections: lists, tuples, sets and dictsThe four built-in containers and the one question that picks between them: what does this data need to be cheap at? 12 min · intro
- Functions: arguments, return values and scopeA function is a named block with its own local scope; arguments go in, one value comes back, and locals vanish when it ends. 12 min · core
Objects and I/O
Classes and instances, inheritance and polymorphic dispatch, exceptions as a control path, and reading and writing files behind modules.
- Classes and objectsA class is a recipe; each instance gets its own attributes while methods live once on the class. 12 min · core
- Inheritance and polymorphismReuse a base class, override the parts that differ, and let method lookup at call time pick the right behaviour. 13 min · core
- Exceptions: a control path, not a crashtry/except/else/finally routes errors to handlers, and finally is the one block that always runs. 12 min · core
- Files and modulesA file object is stateful — a mode and a cursor — and modules turn programs into importable, reusable files. 12 min · core
Data structures
How data is arranged decides what is cheap: contiguous arrays with stack and queue discipline, linked nodes, BSTs and AVL rotations, binary heaps, hash tables with collisions, and graphs.
- Arrays, stacks and queuesA contiguous array with a discipline on top: LIFO for a stack, FIFO for a queue, and why the end is the cheap place to touch. 12 min · core
- Linked listsNodes joined by next pointers trade cheap indexing for cheap insertion, at the cost of chasing memory. 13 min · core
- Trees, BSTs and AVL rotationsA binary search tree orders linked nodes so each comparison halves the search — if it stays balanced, which is what rotations buy. 15 min · advanced
- Heaps and priority queuesA complete tree stored in an array keeps the minimum at the root and both insert and extract in logarithmic time. 13 min · advanced
- Hash tablesA hash function turns a key into an array index, so lookup is one computation — until two keys collide. 13 min · advanced
- Graphs and their representationsVertices and edges model relationships; adjacency lists and matrices are two ways to store the same graph with different costs. 12 min · core
Algorithms
Asymptotic analysis as the currency of choice, comparison sorting from insertion to quicksort and merge sort, linear and binary search, graph traversal with BFS and DFS, and substring search with naive, KMP and Rabin-Karp.
- Complexity and asymptotic analysisBig-O compares how running time grows with input size, ignoring constants and machine speed. 12 min · core
- SortingFrom quadratic insertion and selection sorts to O(n log n) merge and quick sort, and the comparison lower bound they all share. 14 min · core
- Searching: linear and binaryScanning every element is O(n); binary search turns sortedness into O(log n) by halving the range each step. 11 min · core
- Graph traversal: BFS and DFSBreadth-first explores level by level with a queue; depth-first plunges with a stack; both visit every reachable vertex in O(V + E). 13 min · core
- String matching: naive, KMP and Rabin-KarpFinding a pattern in a text: slide and compare naively, or reuse what was matched with KMP, or hash the windows with Rabin-Karp. 14 min · advanced