Unit summary
- Dynamic programming solves overlapping sub-problems once and stores answers: Fibonacci in Θ(n), binomial coefficients in Θ(nk).
- Floyd-Warshall gives all-pairs shortest paths in Θ(n³) by adding intermediate vertices one at a time.
- 0/1 knapsack uses V[i][j] = max(V[i − 1][j], vᵢ + V[i − 1][j − wᵢ]) in Θ(nW).
- BFS (queue) and DFS (stack) both take Θ(V + E); BFS gives unweighted shortest paths.
- Connected components come from repeated traversals.
- DFS on a directed graph finds cycles through back edges and gives a topological order of a DAG.
Glossary
| Term | Meaning |
|---|---|
| Back edge | Edge to an ancestor in DFS. |
| BFS | Breadth first search using a queue. |
| Binomial coefficient | Number of ways to choose k of n. |
| Connected component | Maximal connected set of vertices. |
| DAG | Directed acyclic graph. |
| DFS | Depth first search using a stack. |
| Dynamic programming | Solving overlapping sub-problems once and storing results. |
| Floyd-Warshall | All-pairs shortest path algorithm. |
| In-degree | Number of incoming edges. |
| Memoization | Top-down caching of results. |
| Pseudo-polynomial | Polynomial in the numeric value of the input. |
| Tabulation | Bottom-up filling of a table. |
| Topological sort | Order respecting all edge directions. |
Question bank
Short Answer Questions (2 marks each)
- What is dynamic programming?
- State Pascal's rule.
- Define memoization.
- What is the time complexity of Floyd-Warshall?
- State the recurrence of 0/1 knapsack.
- Which data structure does BFS use?
- What is a connected component?
- What is a back edge?
- Define a DAG.
- What is topological sorting?
Medium Answer Questions (5 marks each)
- Explain memoization and tabulation with Fibonacci.
- Compute C(6, 3) using dynamic programming.
- Explain the Floyd-Warshall algorithm.
- Solve a 0/1 knapsack instance with a table.
- Compare BFS and DFS.
- Explain topological sorting with an example.
Long Answer Questions (15 marks each)
- Explain dynamic programming and solve Fibonacci and binomial coefficients with it.
- Explain Floyd-Warshall with a worked example and analyse it.
- Explain the 0/1 knapsack algorithm with an example and the traceback.
- Explain BFS, DFS, connected components and topological sorting with analysis.
Sources
- Official BCA syllabus Design and Analysis of Algorithms, course code 26BCA404DS03, Unit III
