Steps:

  1. Formulate the problem precisely
  2. Design an algorithm
  3. Prove the algorithm is correct
  4. Analyze its runtime

Algothrm design techniques:

Computational Intractability

P vs NP Problem

Approximation Algorithm

0. Foundational Concepts & Analysis

Asymptotic Analysis:
  • Complexity:
    • An algorithm is efficient if its running time is a polynomial in the input size
      • The running time is upper bounded by for some constants
      • ex: brute force can solve Gale Shapley Algorithm in
    • 2 main complexities:
  • Algorithm’s running time:
    • To measure a Efficient Algorithm
    • is asymptotically bounded by
    • Propositions:
      1. if for some constant then
        • Proof: by definition
        • by definition of Big Theta notation, it is true
      2. if then
      3. if then
    • To find which notation a function belongs to, do
  • Some classes of function:
    • Polynomials:
      • as
    • Logarithms:
      • for every and
      • as
    • Logarithms and Polynomials:
      • for every and every
      • as
    • Exponentials:
      • for every and every
      • as
    • Factorials:
Recursion: Techniques like tail recursion and its relationship with Divide and Conquer.
- Sorting Algorithms: Comparison sorts (Merge SortQuick SortHeap Sort) and non-comparison sorts (Counting SortRadix Sort).

Basic & Linear Data Structures

  • Arrays: Static and dynamic arrays.
  • Linked Lists: Singly, doubly, and circular linked lists.
  • Stacks and Queues: FIFO and LIFO principles, including Deques (Double-ended Queues) and Priority Queues(often implemented with Heaps).
  • Hash Tables / Maps: Hashing techniques and collision resolution (chaining, open addressing).

🌳 Tree Structures

  • Trees and Binary Trees: Traversal methods (Pre-order, In-order, Post-order), tree properties (height, depth).

  • Binary Search Trees (BSTs): Insertion, deletion, and searching.

  • Self-Balancing Trees: Structures like AVL Trees and Red-Black Trees for guaranteed logarithmic time complexity.

  • Tries (Prefix Trees): Used for efficient string retrieval and prefix matching.

  • Heaps: Min-Heaps and Max-Heaps (used in Priority Queues and Heap Sort).

Graph Algorithms & DSU (Union-Find)

- Graph Representations: Adjacency Matrix and Adjacency List.
- Graph Traversal: Breadth-First Search (BFS) and Depth-First Search (DFS).
- Shortest Path Algorithms:
  • Dijkstra’s Algorithm (Single Source Shortest Path for non-negative weights).

  • Bellman-Ford Algorithm (Handles negative weights).

  • Floyd-Warshall Algorithm (All-Pairs Shortest Path).

Minimum Spanning Tree (MST):
  • Kruskal’s Algorithm (which heavily relies on DSU for cycle detection).

  • Prim’s Algorithm.

- Topological Sorting: Ordering nodes in a Directed Acyclic Graph (DAG).
- Flow Networks: Max-Flow Min-Cut Theorem and algorithms like Edmonds-Karp.
Disjoint Set Union

Algorithmic Paradigms

Greedy Algorithms: Making locally optimal choices in the hope of finding a global optimum.
  • Examples: Fractional Knapsack, Activity Selection.
- Divide and Conquer: Breaking a problem into smaller, independent subproblems and combining the solutions.
  • Examples: Merge Sort, Quick Sort, Karatsuba Multiplication.
- Dynamic Programming (DP): Solving overlapping subproblems by storing the results of intermediate computations.
  • Examples: 0/1 Knapsack, Longest Common Subsequence, Fibonacci Sequence.
- Backtracking: A general algorithm for finding all (or some) solutions to computational problems, typically building a solution step by step and abandoning partial solutions if they lead to a dead end.
  • Examples: N-Queens, Sudoku Solver, finding all Hamiltonian Paths.
- Branch and Bound: Similar to Backtracking but uses bounding functions to discard sub-trees in the search space early.

🔬 Advanced Data Structures & Techniques

  • Segment Trees: Efficiently handling range queries and point updates on an array (or vice-versa, with lazy propagation).

  • Fenwick Trees (Binary Indexed Trees - BIT): Another structure for range queries/updates, often simpler to implement than a Segment Tree.

  • String Matching Algorithms: Knuth-Morris-Pratt (KMP)Rabin-Karp.

  • Computational Geometry: Convex Hull, Line Intersection.

  • Network Flow: Advanced applications like Min Cost Max Flow.