Design and Analysis of Algorithms (DAA) Notes
I. Introduction
Algorithms and Analyzing Algorithms
- Algorithm: A step-by-step procedure to solve a problem.
- Analyzing Algorithms: Evaluating an algorithm's performance in terms of time and space complexity.
Complexity of Algorithms
- Time Complexity: Amount of time taken by an algorithm to run as a function of the input size.
- Space Complexity: Amount of memory space required by an algorithm.
Growth of Functions
- Big-O Notation (O): Upper bound of an algorithm's growth rate.
- Omega Notation: Lower bound of an algorithm's growth rate.
- Theta Notation: Tight bound of an algorithm's growth rate.
Performance Measurements
- Execution Time
- Memory Usage
- Input/Output Operations
Sorting and Order Statistics
Sorting Algorithms
1. Shell Sort: Sorting using incrementally smaller gaps.
2. Quick Sort: Divide and conquer; pivot-based partitioning.
3. Merge Sort: Divide and conquer; merging sorted subarrays.
4. Heap Sort: Using binary heaps for sorting.
Design and Analysis of Algorithms (DAA) Notes
Comparison of Sorting Algorithms
- Time Complexity:
- Quick Sort: Average - O(n log n), Worst - O(n^2)
- Merge Sort: O(n log n)
- Heap Sort: O(n log n)
- Space Complexity:
- Quick Sort: O(log n)
- Merge Sort: O(n)
- Heap Sort: O(1)
Sorting in Linear Time
1. Counting Sort: Assumes a range of integer keys; O(n).
2. Radix Sort: Sorts by processing digits; O(nk).
3. Bucket Sort: Divides data into buckets and sorts individually; O(n).
---
II. Advanced Data Structures
Red-Black Trees
- Self-balancing binary search tree.
- Properties ensure O(log n) operations.
B-Trees
- Generalization of binary search trees.
- Used in databases and filesystems.
Design and Analysis of Algorithms (DAA) Notes
Binomial Heaps
- Collection of binomial trees.
- Supports efficient merging of heaps.
Fibonacci Heaps
- Better amortized time complexity for decrease-key and delete operations.
Tries
- Prefix tree for string searching.
- Used in dictionaries and autocomplete systems.
Skip Lists
- Layered linked lists with elements sorted by key.
- Allows O(log n) search, insert, and delete.