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)

  1. What is backtracking?
  2. What is a non-promising node?
  3. State the diagonal attack condition for queens.
  4. How many solutions has the 4-queen problem?
  5. State the pruning conditions of sum of subsets.
  6. Define a Hamiltonian circuit.
  7. What is a vertex cover?
  8. Define P and NP.
  9. What is a non-deterministic algorithm?
  10. Define NP-complete.

Medium Answer Questions (5 marks each)

  1. Explain the backtracking method with the state-space tree.
  2. Solve the 4-queen problem by backtracking.
  3. Solve a sum of subsets instance with M = 9.
  4. Explain the Hamiltonian circuit problem and its backtracking solution.
  5. Explain the classes P and NP with examples.
  6. Distinguish NP-hard and NP-complete problems.

Long Answer Questions (15 marks each)

  1. Explain backtracking and solve the n-Queen problem with analysis.
  2. Explain the sum of subsets problem with a state-space tree and pruning.
  3. Explain Hamiltonian circuit and vertex cover with algorithms and complexity.
  4. 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