0% found this document useful (0 votes)
11 views

DAA Notes Cleaned

Uploaded by

divsnj3008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

DAA Notes Cleaned

Uploaded by

divsnj3008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Design and Analysis of Algorithms (DAA) Notes

1. Introduction to Algorithms

Notes:

- Algorithm: A step-by-step procedure to solve a problem.

- Asymptotic Notations:

- Big O: Upper bound (worst-case complexity).

- Theta: Tight bound (average-case complexity).

- Omega: Lower bound (best-case complexity).

- Recurrence Relations:

- Solved using substitution, recurrence trees, and Master Theorem:

- T(n) = aT(n/b) + O(n^d), compare log_a(b) with d.

Important Questions:

- Short: Define Big O, Theta, and Omega with examples.

- Long: Solve the recurrence T(n) = 2T(n/2) + n using the Master Theorem.

2. Divide and Conquer

Notes:

- Divide the problem into sub-problems, conquer them independently, and combine the results.

- Examples:

- Merge Sort: Time Complexity = O(n log n).

- Quick Sort: Avg. Time Complexity = O(n log n), Worst = O(n^2).

- Strassen's Matrix Multiplication: Reduces multiplication operations.

Important Questions:
- Short: Explain the difference between Merge Sort and Quick Sort.

- Long: Write and analyze the algorithm for Merge Sort.

3. Greedy Algorithms

Notes:

- Constructs the solution step-by-step by choosing the locally optimal solution.

- Examples:

- Huffman Encoding: Used for data compression.

- Kruskal's and Prim's algorithms: Find Minimum Spanning Tree.

- Dijkstra's Algorithm: Shortest path in a weighted graph.

Important Questions:

- Short: State the greedy choice property with an example.

- Long: Explain Huffman Encoding with an example.

4. Dynamic Programming

Notes:

- Overlapping sub-problems and optimal substructure.

- Examples:

- 0/1 Knapsack Problem: Use DP table.

- Longest Common Subsequence (LCS): Compare substrings iteratively.

- Matrix Chain Multiplication: Minimize scalar multiplications.

Important Questions:

- Short: Differentiate between dynamic programming and greedy algorithms.

- Long: Solve the 0/1 Knapsack problem with a DP table.


5. Backtracking

Notes:

- Explore all possibilities; backtrack when a condition fails.

- Examples:

- N-Queens Problem: Place queens on an N x N board.

- Hamiltonian Cycle: Find a cycle visiting all vertices once.

- Subset Sum Problem: Find subsets that sum to a target.

Important Questions:

- Short: Write the backtracking condition for N-Queens.

- Long: Write and explain the algorithm for the Hamiltonian Cycle problem.

6. Branch and Bound

Notes:

- Systematic enumeration of candidate solutions.

- Examples:

- Travelling Salesman Problem (TSP): Find the shortest tour.

- 0/1 Knapsack: Use bounding function to eliminate candidates.

Important Questions:

- Short: What is a bounding function?

- Long: Solve a TSP problem using branch and bound.

7. Graph Algorithms

Notes:

- BFS and DFS: Traverse all nodes.

- Topological Sort: Sort DAG nodes such that for every edge u -> v, u comes before v.
- Strongly Connected Components (SCC): Kosaraju's Algorithm.

Important Questions:

- Short: Differentiate between BFS and DFS.

- Long: Write and explain Kosaraju's Algorithm for SCC.

8. NP-Completeness and Approximation Algorithms

Notes:

- NP-Hard: No polynomial-time solution exists.

- NP-Complete: Verification in polynomial time.

- Approximation Algorithms: Provide near-optimal solutions.

Important Questions:

- Short: Define NP-Complete problems with examples.

- Long: Explain SAT problem and its NP-Completeness.

9. Advanced Topics (Optional)

Notes:

- Ford-Fulkerson: Calculates maximum network flow.

- Randomized Algorithms: Use random numbers for decision-making.

Important Questions:

- Short: What is the importance of the Ford-Fulkerson algorithm?

- Long: Write and analyze the randomized quicksort algorithm.

Additional Questions

Short Questions
1. Define time complexity and space complexity.

2. Explain the difference between Divide and Conquer and Dynamic Programming.

3. State the Bellman-Ford Algorithm and its use.

Long Questions

1. Solve the Longest Common Subsequence problem using Dynamic Programming.

2. Explain Dijkstra's Algorithm with an example.

3. Write and analyze the Quick Sort algorithm.

You might also like