ADA Revision Sheet
ADA Revision Sheet
- Asymptotic Notations:
- Big O (O): Upper bound (worst-case)
- Omega (Omega): Lower bound (best-case)
- Theta (Theta): Tight bound (average-case)
- Common Complexities: O(1), O(log n), O(n), O(n log n), O(n²), O(2^n)
- Time Complexities:
- Bubble/Selection Sort: O(n²)
- Merge Sort / Quick Sort (avg): O(n log n)
- Binary Search: O(log n)
- Matrix Multiplication (Strassen): ~O(n^2.81)
- Tree Traversals:
- Inorder: Left, Root, Right
- Preorder: Root, Left, Right
- Postorder: Left, Right, Root
- Greedy Algorithms:
- Activity Selection: Choose earliest finishing first
- Huffman Coding: Use min-heap to combine least freq nodes
- MST: Kruskals (edges, sort), Prims (priority queue)
- Dijkstras: Shortest Path (min-priority queue)
- Graph Algorithms:
- BFS: Queue, level-order
- DFS: Stack/recursion, depth-first
- Warshalls: Transitive closure
- Floyds: All-pairs shortest path (DP)
- NP-Complete Topics:
- P: Solvable in poly time
- NP: Verifiable in poly time
- NP-Complete: In NP + All NP problems reduce to it
- Examples: n-Queens, Hamiltonian Circuit, Subset Sum, TSP
- Backtracking:
- Try Recurse Undo (e.g., n-Queens)
- Used when brute force is too slow
- Tip: Always write time complexity & identify algorithm class (Greedy, DP, etc.)