Programming core
Data Structures
5 self-contained study topics — notes, diagrams, formulas, and worked examples for exams and GATE.
Topics
- Arrays and Linked ListsArrays store elements contiguously for O(1) indexed access but need shifting to insert, while linked lists store nodes with pointers for O(1) insertion at a known position but require O(n) traversal to locate an element.
- Stacks and QueuesA stack is a last-in-first-out structure (push/pop at one end) used for nesting and backtracking, while a queue is first-in-first-out (enqueue rear, dequeue front) used for ordered processing; both support O(1) operations.
- Trees and Binary Search TreesA binary search tree keeps smaller keys left and larger keys right, giving O(log n) search, insert and delete when balanced; an inorder traversal visits keys in sorted order, and self-balancing variants use rotations to bound the height.
- Graphs and TraversalsGraphs model relationships as vertices and edges, stored as an adjacency matrix (fast lookup, O(V²) space) or list (compact for sparse graphs); breadth-first and depth-first traversals both run in O(V+E) and answer different questions.
- Hashing TechniquesHashing maps keys to table slots via a hash function for near O(1) average lookup; collisions (two keys to one slot) are resolved by chaining or open addressing, and performance degrades as the load factor rises.