Here’s a compact version for your micronotes, tailored for quick reference during exams:
Design and Analysis of Algorithms: Creating efficient algorithms and evaluating their time and space complexity. Focuses on correctness, optimal performance, and resource usage.
Asymptotic Notations: Symbols to describe algorithm growth with input size.
- Big-O: Worst-case (upper bound).
- Big-Ω: Best-case (lower bound).
- Big-Θ: Tight bound (average case).
- E.g., O(nlogn)O(n \log n) for Merge Sort means time grows logarithmically with input size.
Recursion and Recurrence Relations: Recursion solves problems by calling the same function for smaller inputs (e.g., Fibonacci series). Recurrence relations describe the runtime of recursive problems, solved using methods like substitution or Master Theorem (e.g., T(n)=T(n/2)+O(1)T(n) = T(n/2) + O(1)).
Sorting: Process of arranging elements in order.
- Bubble: Adjacent swaps.
- Quick: Pivot-based divide and conquer.
- Merge: Recursive merging.
- Heap: Uses heap structure.
- Efficient sorting (e.g., Merge/Quick) has O(nlogn)O(n \log n) time complexity.
Knapsack Problem: Optimization problem to maximize value within a weight limit.
- 0/1 Knapsack: Items are either picked or skipped, solved using Dynamic Programming.
- Fractional Knapsack: Items can be split, solved using Greedy approach.
Minimum Spanning Tree (MST): A tree connecting all graph vertices with minimal edge weight.
- Prim’s Algorithm: Adds smallest-weight edges starting from one vertex.
- Kruskal’s Algorithm: Picks smallest edges while avoiding cycles.
Heap: A binary tree that maintains the heap property (parent node is larger/smaller than children).
- Max-Heap: Parent > children.
- Min-Heap: Parent < children.
- Used in priority queues and Heap Sort (O(logn)O(\log n) operations).
Activity Selection: Problem of choosing maximum non-overlapping activities. Sort by finish times and pick greedily. E.g., scheduling meetings efficiently.
Huffman Coding: A Greedy compression algorithm where frequent elements get shorter codes. Builds a binary Huffman Tree. Used in ZIP files, MP3, and other formats.
1. Design and Analysis of Algorithms
Definition: It is the process of creating algorithms to solve problems efficiently and analyzing their performance.
Explanation:
- Design involves techniques like Divide and Conquer, Dynamic Programming, and Greedy approaches.
- Analysis evaluates the algorithm's time complexity (how fast it runs) and space complexity (how much memory it uses).
2. Asymptotic Notations
Definition: Symbols used to describe the running time of algorithms as the input size grows.
Explanation:
- Big-O (O): Upper bound; worst-case time.
- Big-Ω (Ω): Lower bound; best-case time.
- Big-Θ (Θ): Tight bound; average-case time.
- Example: For a sorting algorithm with complexity O(nlogn)O(n \log n), doubling the input doubles the time approximately.
3. Recursion and Recurrence Relations
Recursion:
- Definition: A technique where a function calls itself to solve smaller sub-problems.
- Example: Fibonacci series:
- F(n)=F(n−1)+F(n−2)F(n) = F(n-1) + F(n-2).
Recurrence Relations:
- Definition: Equations that express a problem in terms of its smaller sub-problems.
- Example: T(n)=T(n/2)+O(1)T(n) = T(n/2) + O(1).
- Used to analyze the time complexity of recursive algorithms.
4. Sorting
Definition: Arranging elements in a specific order (ascending/descending).
Explanation:
- Bubble Sort: Repeatedly swap adjacent elements.
- Quick Sort: Divide using a pivot; sort parts.
- Merge Sort: Divide array, merge sorted parts.
- Heap Sort: Use heap data structure.
- Best algorithms like Merge and Quick have O(nlogn)O(n \log n) complexity.
5. Knapsack Problem
Definition: Optimization problem where items with weights and values are chosen to maximize value within a weight limit.
Explanation:
- 0/1 Knapsack: Items are either picked or not. Solved using Dynamic Programming.
- Fractional Knapsack: Items can be split. Solved using Greedy algorithms.
- Applications: Resource allocation.
6. Minimum Spanning Tree (MST)
Definition: A tree connecting all vertices of a graph with the minimum total edge weight.
Explanation:
- Prim’s Algorithm: Start with one vertex; add edges with the least weight.
- Kruskal’s Algorithm: Sort edges; pick the smallest weight edges while avoiding cycles.
- Applications: Network design, circuit design.
7. Heap
Definition: A complete binary tree that satisfies the heap property.
Explanation:
- Max-Heap: Parent node is greater than or equal to children.
- Min-Heap: Parent node is smaller than or equal to children.
- Applications: Priority queues, sorting (Heap Sort).
- Operations like insert and delete run in O(logn)O(\log n).
8. Activity Selection
Definition: A problem to select the maximum number of activities that don’t overlap.
Explanation:
- Sort activities by their finish times.
- Iteratively select activities that start after the previous activity finishes.
- Uses Greedy approach. Example: Scheduling meetings.
9. Huffman Coding
Definition: A Greedy algorithm for lossless data compression.
Explanation:
- Frequently used characters get shorter binary codes.
- Construct a binary tree (Huffman Tree) based on character frequencies.
- Applications: File compression formats like ZIP and MP3.