Data Structures
Data structures and algorithms are the toolkit behind every efficient program, and a core GATE CS subject. Each lesson explains one idea with figures, gives the code in Java, Python and C, and ends with GATE-style practice questions.
1Getting Started
- Introduction to Data StructuresWhat data structures and algorithms are, the main kinds, and why the choice matters.
- Time and Space ComplexityMeasure how running time grows with input size using Big-O, Big-Omega and Big-Theta.
- Recursion and Recurrence RelationsHow recursive calls run, and how to find their running time with recursion trees and the master theorem.
2Linear Data Structures
- Arrays and Dynamic ArraysConstant-time indexing, address calculation, and how growable arrays stay fast.
- Linked ListsNodes connected by pointers, with O(1) insertion at the front and no fixed size.
- StacksLast in, first out. Function calls, undo, bracket matching and postfix evaluation.
- Queues and DequesFirst in, first out. Circular arrays, double-ended queues and where queues are used.
3Hashing
4Trees
- Binary Trees and TraversalsTree terminology, the four classic traversals, height and counting nodes.
- Binary Search TreesKeep keys ordered so search, insert and delete take time proportional to the height.
- AVL Trees (Self-Balancing BSTs)Keep a BST balanced with rotations so search, insert and delete stay O(log n) in the worst case.
- Heaps and Priority QueuesA complete binary tree stored in an array that always gives you the smallest (or largest) item fast.
5Graphs
- Graphs, BFS and DFSRepresent networks with adjacency lists and matrices, and explore them breadth-first and depth-first.
- DFS Applications (Edge Types, Cycles, Components)Discovery and finish times, classifying edges, detecting cycles and finding strongly connected components.
- Shortest Paths (Dijkstra and Bellman-Ford)Find the cheapest route in a weighted graph, and know when negative edges break things.
- Minimum Spanning Trees (Kruskal and Prim)Connect every vertex with the least total edge weight, using greedy algorithms.
6Searching and Sorting
- Searching (Linear and Binary Search)Linear search, binary search and its variants, and searching on the answer.
- Simple Sorting (Bubble, Selection, Insertion)Three easy O(n²) sorts, how many swaps and comparisons they make, and when they are still useful.
- Fast Sorting (Merge, Quick, Counting)Divide-and-conquer sorts in O(n log n), the comparison lower bound, and linear-time counting sort.
7Algorithm Design Techniques
- Divide and ConquerSplit, solve recursively, combine. Fast exponentiation, max-min, maximum subarray and fast multiplication.
- Greedy AlgorithmsMake the locally best choice at every step. Activity selection, fractional knapsack and Huffman coding.
- Dynamic ProgrammingSolve problems with overlapping subproblems by remembering answers, with Fibonacci, coin change, LCS and knapsack.