Unit summary
- Some problems are unsolvable or need exponential time; backtracking prunes a state-space tree.
- n-Queen uses column and diagonal tests; 4 queens have 2 solutions, 8 queens have 92.
- Sum of subsets prunes when s + next > M or s + remaining < M.
- Hamiltonian circuit visits every vertex once (O(n!)); vertex cover covers every edge, with a 2-approximation.
- P is solvable in polynomial time, NP verifiable in polynomial time; P ⊆ NP and P = NP is open.
- NP-complete problems are in NP and NP-hard; SAT was the first.
Glossary
| Term | Meaning |
|---|---|
| Approximation algorithm | Fast algorithm with guaranteed quality. |
| Backtracking | Depth-first search with pruning. |
| Bounding function | Test of whether a node is promising. |
| Decision problem | A problem with a yes or no answer. |
| Hamiltonian circuit | Cycle through every vertex once. |
| n-Queen | Place n non-attacking queens. |
| NP | Polynomial-time verifiable problems. |
| NP-complete | In NP and NP-hard. |
| NP-hard | At least as hard as every NP problem. |
| P | Polynomial-time solvable problems. |
| Reduction | Converting one problem to another. |
| SAT | Boolean satisfiability problem. |
| State-space tree | Tree of partial solutions. |
| Sum of subsets | Find subsets with a given sum. |
| Vertex cover | Vertices touching every edge. |
Question bank
Short Answer Questions (2 marks each)
- What is backtracking?
- What is a non-promising node?
- State the diagonal attack condition for queens.
- How many solutions has the 4-queen problem?
- State the pruning conditions of sum of subsets.
- Define a Hamiltonian circuit.
- What is a vertex cover?
- Define P and NP.
- What is a non-deterministic algorithm?
- Define NP-complete.
Medium Answer Questions (5 marks each)
- Explain the backtracking method with the state-space tree.
- Solve the 4-queen problem by backtracking.
- Solve a sum of subsets instance with M = 9.
- Explain the Hamiltonian circuit problem and its backtracking solution.
- Explain the classes P and NP with examples.
- Distinguish NP-hard and NP-complete problems.
Long Answer Questions (15 marks each)
- Explain backtracking and solve the n-Queen problem with analysis.
- Explain the sum of subsets problem with a state-space tree and pruning.
- Explain Hamiltonian circuit and vertex cover with algorithms and complexity.
- Explain non-deterministic algorithms, P, NP, NP-complete and NP-hard with reductions and Cook's theorem.
Sources
- Official BCA syllabus Design and Analysis of Algorithms, course code 26BCA404DS03, Unit IV
