21CSE07 DESIGN AND ANALYSIS OF ALGORITHM
QUESTION BANK
UNIT-1
ANALYSIS & DIVIDE-AND-CONQUOR
2-Marks Questions:
1. Define an algorithm. What are the characteristics of a good algorithm?
2. Explain the term "asymptotic analysis" of an algorithm.
3. What is the difference between a deterministic and a nondeterministic algorithm?
4. Explain the concept of algorithm efficiency and its importance.
5. What is the significance of "Big-O" notation in algorithm analysis?
6. What is the difference between time complexity and space complexity?
7. Define the term "greedy algorithm" with an example.
8. Define "Big-O" notation and give an example.
9. What is "Big-Omega" notation? Provide an example.
10. What is "Theta" notation? How does it differ from Big-O notation?
11. Explain the concept of "amortized analysis" in algorithms.
12. What is the difference between worst-case and average-case time complexity?
13. Explain the term "polynomial time complexity" with an example.
14. Define the terms "logarithmic time" and "linear time" with examples.
15. What is a recurrence equation? Provide an example.
16. Explain the substitution method for solving recurrence equations.
17. Define the iteration method for solving recurrence relations with an example.
18. What is the Master Theorem? How is it used to solve recurrence relations?
19. Solve the recurrence relation T(n)=2T(n/2)+nT(n) = 2T(n/2) + nT(n)=2T(n/2)+n using the
master theorem.
20. Explain the concept of divide-and-conquer and how it relates to recurrence relations.
21. What is the time complexity of the Merge Sort algorithm? Justify your answer using
recurrence relations.
Big Questions:
1. Describe the classification of algorithms based on their time and space complexities.
Discuss the importance of choosing an efficient algorithm.
2. Discuss different algorithm design techniques with examples: divide and conquer,
greedy approach, dynamic programming, and backtracking.
3. What are the different types of algorithms used for searching and sorting? Discuss their
time and space complexities.
4. Explain the difference between Big-O, Big-Omega, and Theta notation with examples.
How are they used to describe the time complexity of algorithms?
5. Discuss the different categories of time complexity (constant time, logarithmic time,
linear time, etc.) with examples and their practical significance.
6. How do we analyze the space complexity of an algorithm? Discuss with the help of an
example.
7. Discuss the growth rates of common functions in terms of Big-O notation: constant,
logarithmic, linear, quadratic, cubic, and exponential.
8. Solve the recurrence T(n)=3T(n/4)+nT(n) = 3T(n/4) + nT(n)=3T(n/4)+n using the master
theorem. Discuss how the result is derived.
9. Explain the substitution method for solving recurrence relations. Solve
T(n)=2T(n/2)+nT(n) = 2T(n/2) + nT(n)=2T(n/2)+n using the substitution method.
10. Discuss the Iteration Method for solving recurrences. Solve T(n)=T(n−1)+O(1)T(n) = T(n-
1) + O(1)T(n)=T(n−1)+O(1) using the iteration method.
11. Use the Master Theorem to solve the recurrence T(n)=2T(n/2)+n2T(n) = 2T(n/2) +
n^2T(n)=2T(n/2)+n2. Provide a detailed explanation of each step.
UNIT-2
GREEDY & DYNAMIC PROGRAMMING
2-Marks Questions:
1. What is a greedy algorithm? Explain its basic principle.
2. Define the term "optimal solution" in the context of greedy algorithms.
3. Explain the concept of the "Knapsack problem." What are its types?
4. What are the necessary conditions for applying a greedy approach to solve a problem?
5. Explain why a greedy algorithm is not always optimal with an example.
6. What is the difference between a "fractional knapsack" and a "0/1 knapsack" problem?
7. State the properties of the minimum cost spanning tree (MST) in a weighted graph.
8. What is Prim’s algorithm used for, and how does it work in finding the MST?
9. Define Dijkstra’s algorithm. What problem does it solve?
10. In the context of the Single Source Shortest Path problem, what does the term
"relaxation" mean?
11. What is dynamic programming (DP)? How is it different from the greedy approach?
12. Define the principle of optimality in dynamic programming.
13. What is the role of memoization in dynamic programming?
14. Describe the concept of overlapping subproblems with an example.
15. What is the All-Pairs Shortest Path problem? Name a DP algorithm used to solve it.
16. Explain the Longest Common Subsequence (LCS) problem with an example.
17. What are the main differences between the traveling salesperson problem (TSP) and the
knapsack problem?
18. What is Bellman-Ford algorithm used for in dynamic programming?
19. How does dynamic programming help in solving the Fibonacci sequence problem?
Illustrate with an example.
20. Explain how the shortest path problem can be solved using dynamic programming.
Big Questions:
1. Explain the greedy approach to solve the 0/1 Knapsack problem. How does it differ from
the fractional knapsack problem?
2. Derive and explain the steps of Prim's Algorithm to find the Minimum Spanning Tree in a
connected, undirected graph.
3. Discuss Dijkstra’s algorithm for solving the Single Source Shortest Path problem.
Provide a step-by-step example.
4. Explain Kruskal’s algorithm for finding the Minimum Spanning Tree (MST) of a graph.
Illustrate with an example.
5. What is the time complexity of the greedy algorithms for MST and the shortest path
problems? Compare with the time complexity of dynamic programming-based solutions.
6. Explain the principle of optimality in dynamic programming. How does it help in solving
problems efficiently?
7. Solve the Traveling Salesperson Problem (TSP) using dynamic programming and
explain the step-by-step approach.
8. Derive and explain the dynamic programming approach to solve the All-Pairs Shortest
Path problem.
9. Discuss the dynamic programming approach for solving the Longest Common
Subsequence (LCS) problem with a detailed example.
10. Explain the Bellman-Ford algorithm and how it is used to solve the Single Source
Shortest Path problem with negative weights.
11. What is the time complexity of dynamic programming algorithms like LCS and TSP?
Compare it with the greedy approach.
12. Solve the following problem using dynamic programming: Given a sequence of integers,
find the maximum sum of a subsequence such that no two elements are adjacent.
UNIT-3
BACKTRACKING & BRANCH-AND-BOUND
2-Marks Questions:
1. What is backtracking? Explain its general method.
2. Describe the concept of "state space tree" in backtracking.
3. What are the advantages and disadvantages of the backtracking algorithm?
4. How does backtracking differ from the brute force approach?
5. Define "pruning" in the context of backtracking. Why is it useful?
6. What is the significance of the concept of "feasible solution" in backtracking?
7. How does backtracking ensure that all possible solutions are explored?
8. What is the 8-Queens problem? Explain the constraints that must be satisfied.
9. How can the 8-Queens problem be solved using backtracking?
10. Explain how you would represent the board in the 8-Queens problem.
11. How does backtracking help in efficiently solving the 8-Queens problem?
12. What is the basic idea of pruning in the 8-Queens problem?
13. What is the graph coloring problem? Explain its objective.
14. What is the significance of using backtracking to solve the graph coloring problem?
15. How do you ensure that no two adjacent vertices are assigned the same color in graph
coloring?
16. Define "chromatic number" in the context of graph coloring.
17. How do you determine the minimum number of colors needed for graph coloring?
18. What is the sum of subset problem? How is it related to the subset-sum problem?
19. How can the sum of subset problem be solved using backtracking?
20. Explain how you can represent the subsets in the sum of subset problem.
21. What are the conditions for pruning in the sum of subset problem?
22. Describe the process of checking whether a subset sum equals a target value.
23. What is the Hamiltonian cycle problem? What is its objective?
24. How can backtracking be used to solve the Hamiltonian cycle problem?
25. What is the difference between a Hamiltonian cycle and an Eulerian cycle?
26. Define the constraints for finding a Hamiltonian cycle using backtracking.
27. How do you represent the graph in the Hamiltonian cycle problem?
28. What is the branch and bound technique? How does it differ from backtracking?
29. Explain the role of bounds in the branch and bound method.
30. How does the branch and bound algorithm reduce the solution space?
31. What is the "bounding function" in the context of branch and bound?
32. What are the types of bounds used in branch and bound techniques?
33. What is the knapsack problem? Explain its objective.
34. What is the difference between the 0/1 knapsack problem and the fractional knapsack
problem?
35. How is the knapsack problem solved using the branch and bound technique?
36. What is the role of the bounding function in solving the knapsack problem?
37. Explain how the "best-first" search strategy is used in the branch and bound method for
the knapsack problem.
38. What is the traveling salesman problem (TSP)? Explain the objective.
39. How can the traveling salesman problem be solved using branch and bound?
40. What is the significance of the lower bound in branch and bound for TSP?
41. How do you define the objective function in the TSP when using branch and bound?
42. What are the challenges involved in solving the TSP using branch and bound?
Big Questions:
1. Explain the backtracking algorithm with a generic approach. Illustrate it with an example.
2. Discuss the time complexity of the backtracking algorithm. How can pruning help in
reducing it?
3. Explain the concept of the "state space tree" in backtracking and how it helps in solving
problems like the 8-Queens problem.
4. Solve the 8-Queens problem using backtracking. Provide a step-by-step explanation of
the algorithm.
5. Discuss how the 8-Queens problem can be generalized to the N-Queens problem using
backtracking.
6. Analyze the time complexity of the backtracking algorithm used to solve the 8-Queens
problem.
7. Explain the backtracking algorithm used to solve the graph coloring problem. Provide an
example of how it works.
8. How can the backtracking algorithm be optimized to reduce the number of colors used in
the graph coloring problem? Discuss its limitations.
9. What is the time complexity of the backtracking algorithm for solving the graph coloring
problem? How can it be reduced?
10. Solve the sum of subset problem using backtracking. Provide a step-by-step explanation
and show how pruning is applied.
11. Discuss the backtracking approach for solving the sum of subset problem. How does it
compare to brute force methods?
12. Analyze the time complexity of the backtracking solution to the sum of subset problem.
13. Solve the Hamiltonian cycle problem using backtracking. Provide a step-by-step
explanation of the algorithm.
14. Discuss the challenges faced in solving the Hamiltonian cycle problem using
backtracking. How does pruning help in reducing the search space?
15. Compare the Hamiltonian cycle problem with the traveling salesperson problem. Discuss
their similarities and differences in terms of backtracking solutions.
16. Discuss the general approach of the branch and bound algorithm. How does it differ
from backtracking in solving optimization problems?
17. Explain the concepts of "upper bound" and "lower bound" in branch and bound. How are
they used to prune the search tree?
18. Discuss the time complexity of the branch and bound technique. How does it compare to
backtracking in terms of efficiency?
19. Solve the 0/1 knapsack problem using the branch and bound technique. Provide an
example and discuss the bounding strategy used.
20. Compare and contrast the dynamic programming approach and the branch and bound
approach for solving the knapsack problem.
21. Analyze the time complexity of the branch and bound algorithm for solving the knapsack
problem.
22. Solve the traveling salesman problem using branch and bound. Provide a step-by-step
explanation of how the search tree is built.
23. Discuss the advantages and disadvantages of using branch and bound for solving the
TSP compared to other methods like dynamic programming or nearest neighbor.
24. Analyze the time complexity of the branch and bound algorithm for the traveling
salesman problem. How does the bounding function help in reducing the search space?
UNIT-4
STRING MATCHING & PARALLEL ALGORITHMS
2-Marks Questions :
1. What is the string matching problem? Provide an example.
2. Define Naive String Matching Algorithm. What is its time complexity?
3. What is the KMP algorithm? How does it improve over the naive string matching
algorithm?
4. What is the role of the partial match table (also known as the "prefix function") in the
KMP algorithm?
5. Explain the time complexity of the KMP algorithm.
6. Describe the bad character heuristic in the Boyer-Moore algorithm.
7. How does the Boyer-Moore algorithm improve upon the naive string matching algorithm
in terms of worst-case time complexity?
8. What is the partial match in the KMP algorithm? Explain with an example.
9. What does the term pattern matching mean in computer science?
10. What is a parallel algorithm? How does it differ from a sequential algorithm?
11. Explain the PRAM (Parallel Random Access Machine) model. What are its types?
12. What is the significance of parallelism in algorithms?
13. What are the requirements for an algorithm to be parallelizable?
14. Define the concept of Prefix Computation in parallel algorithms.
15. What is List Ranking in parallel algorithms? How is it useful?
16. Describe the Odd-Even Merge Sort algorithm and its parallel properties.
17. What is the time complexity of Odd-Even Merge Sort in a parallel computing model?
18. Explain the Mesh network model in parallel algorithms. How does it help in sorting?
19. Describe the concept of Bitonic Sort in parallel algorithms. How is it different from other
sorting algorithms?
20. What are the key advantages of parallel algorithms in comparison to sequential ones?
21. How does Parallel Prefix Computation work? Provide an example.
22. Explain List Ranking and how it can be computed in parallel.
23. What is the time complexity of Bitonic Sort in a parallel model?
24. How does the Odd-Even Merge Sort algorithm utilize parallelism in sorting?
Big Questions (10 Questions):
1. Explain the KMP string matching algorithm in detail. Illustrate its working with an
example and discuss its time complexity.
2. Describe the Boyer-Moore string matching algorithm. How does it use both the bad
character rule and the good suffix rule? Provide an example.
3. Compare and contrast the Naive, KMP, and Boyer-Moore algorithms in terms of their
time complexities and practical performance.
4. Derive the time complexity of the KMP algorithm and explain how it improves upon the
brute force approach.
5. Discuss the pattern matching problem and explain how both KMP and Boyer-Moore
solve this problem efficiently. Compare their efficiencies.
6. Explain the concept of the prefix table in the KMP algorithm and how it helps in speeding
up the string matching process.
7. How does the Boyer-Moore algorithm utilize the bad character and good suffix rules?
Provide a step-by-step explanation with an example.
8. What are the main performance differences between the Naive, KMP, and Boyer-Moore
algorithms? When is each algorithm more efficient?
9. How does the KMP algorithm handle mismatches? Describe the process of the pattern
and text alignment.
10. Illustrate with an example how the Boyer-Moore algorithm performs better than the naive
algorithm, particularly in the case of large text.
11. Discuss the PRAM model in parallel computing. Explain its types and how it helps in
designing parallel algorithms.
12. Explain the Odd-Even Merge Sort algorithm in parallel computing. Provide a detailed
example and analyze its parallel time complexity.
13. Describe the Bitonic Sort algorithm. How does it work in parallel environments?
Compare its time complexity with other parallel sorting algorithms.
14. Explain the concept of parallel prefix computation. How is it implemented in parallel
algorithms? Provide an example.
15. Describe List Ranking and explain how it can be computed in parallel. What is its
significance in parallel algorithms?
16. Discuss the mesh network model used in parallel computing. How does it aid in sorting
algorithms like Odd-Even Merge Sort?
17. Illustrate the application of Bitonic Sort in parallel computing. How does it achieve sorting
efficiency in parallel systems?
18. Compare and contrast Odd-Even Merge Sort and Bitonic Sort in parallel computing.
Discuss their advantages and disadvantages.
19. Discuss parallel sorting algorithms in general, and explain the differences between
Bitonic Sort, Odd-Even Merge Sort, and other parallel sorting algorithms.
20. Analyze the time complexity of parallel algorithms in the context of sorting on different
parallel models, including mesh and PRAM.
UNIT-5
NP PROBLEMS & APPROXIMATION ALGORITHMS
2-Marks Questions (10 Questions):
1. What is NP-completeness? Explain the concept in simple terms.
2. Define polynomial-time verification. Why is it important in determining whether a problem
is NP-complete?
3. What is NP-hard? How does it differ from NP-complete?
4. What is the significance of polynomial-time reductions in the theory of NP-
completeness?
5. Explain the concept of NP-completeness proof with respect to a specific problem.
6. What is the relationship between NP and P? Can you provide an example of a problem
that lies in NP?
7. Define circuit satisfiability. How is it related to the NP-complete classification?
8. What are the two basic properties of NP-complete problems?
9. What is the Cook-Levin theorem? How does it help in proving NP-completeness?
10. How does polynomial-time verification work in the context of an NP-complete problem?
11. What is the Vertex Cover problem, and why is it NP-complete?
12. Describe the Hamiltonian Cycle problem and explain its NP-completeness.
13. What is the Traveling Salesman Problem (TSP), and why is it considered NP-complete?
14. How does NP-completeness affect the ability to find optimal solutions for problems like
TSP, Hamiltonian cycle, and Vertex Cover?
15. How is the Vertex Cover problem usually represented, and what is the typical approach
for solving it approximately?
16. What are the approximation algorithms used to find a solution to the Vertex Cover
problem? Briefly describe one of these algorithms.
17. What is a greedy approximation algorithm? How is it applied to problems like Traveling
Salesman Problem or Vertex Cover?
18. What is a polynomial-time approximation scheme (PTAS), and how does it apply to TSP
or Vertex Cover?
19. In the Hamiltonian cycle problem, what does it mean for a graph to have a Hamiltonian
cycle? What are the difficulties in solving it?
20. Why is the Traveling Salesman Problem (TSP) considered NP-complete, and what are
the primary challenges in solving it?
21. What is an approximation algorithm? Why are they important for NP-complete
problems?
22. What is the approximation ratio? How is it used to measure the quality of an
approximation algorithm?
23. What is the greedy algorithm for the Vertex Cover problem? How does it work, and what
is its approximation ratio?
24. Describe an approximation algorithm for the Traveling Salesman Problem.
25. What is the Christofides algorithm? How is it used to approximate solutions for the
Traveling Salesman Problem?
26. How does the 2-approximation algorithm for the Vertex Cover problem work?
27. What is the hardness of approximation? Provide an example of a problem where finding
an approximate solution is as hard as solving the problem itself.
28. How does the greedy algorithm for the Traveling Salesman Problem work? What are its
limitations?
Big Questions (10 Questions):
1. What is NP-completeness? Explain the theory behind it, and discuss how to prove that a
problem is NP-complete. Provide examples of problems that are NP-complete.
2. Explain the concept of polynomial-time verification in the context of NP problems. How
does polynomial-time verification help in identifying NP-complete problems?
3. What is the theory of reducibility in NP-completeness? Explain how one can reduce an
NP-complete problem to another problem and the significance of this process.
4. Discuss the concept of circuit satisfiability and explain why it is NP-complete. How is this
problem related to other NP-complete problems like the satisfiability problem?
5. Discuss how to prove that a problem is NP-complete. Walk through the steps of proving
the NP-completeness of a problem using polynomial-time reductions and providing the
necessary argumentation.
6. Explain the difference between NP-complete, NP-hard, and problems in NP. Provide
examples of each and explain their relationship in terms of time complexity.
7. What is the Hamiltonian cycle problem, and why is it NP-complete? Discuss how the
Hamiltonian cycle problem is proved to be NP-complete using polynomial-time
reductions.
8. Explain the concept of the Vertex Cover problem. How is it proved to be NP-complete,
and what makes it computationally hard to solve?
9. Discuss the Traveling Salesman Problem (TSP). Why is TSP NP-complete, and what
are the challenges in solving this problem in polynomial time?
10. What are the implications of a problem being NP-complete? Discuss why such problems
are considered difficult to solve and how they impact practical applications in fields like
cryptography and optimization.
11. Explain the concept of approximation algorithms. Discuss why they are crucial in solving
NP-complete problems and provide examples of approximation algorithms for problems
like Vertex Cover and TSP.
12. Describe the greedy approximation algorithm for the Vertex Cover problem. Analyze its
time complexity and approximation ratio.
13. Explain the Vertex Cover problem in detail. Why is it considered NP-complete, and how
do we approach finding an optimal or approximate solution?
14. Discuss the Hamiltonian cycle problem. Why is it NP-complete, and how is it different
from the Eulerian cycle problem? Provide an example of the problem.
15. Explain the Traveling Salesman Problem (TSP) in the context of NP-completeness. Why
is it NP-complete, and what are the challenges in finding an optimal solution to this
problem?
16. Discuss the approximation algorithm for the Vertex Cover problem. Provide an
explanation of how the greedy approach works and analyze its approximation ratio.
17. What is the difference between exact and approximate algorithms? Discuss the trade-
offs involved in using approximation algorithms for NP-complete problems like TSP and
Vertex Cover.
18. Explain the polynomial-time approximation scheme (PTAS). How can it be applied to the
Traveling Salesman Problem (TSP)? Discuss its efficiency and limitations.
19. Discuss the importance of polynomial-time reductions in proving the NP-completeness of
problems. Provide an example of how one can reduce a problem to the Vertex Cover or
Hamiltonian Cycle problem.
20. Describe the NP-completeness of the Hamiltonian Cycle problem. Discuss its
significance in graph theory and its relation to other NP-complete problems.
21. Explain how the approximation algorithm for the Traveling Salesman Problem works.
Discuss its time complexity and how close it is to the optimal solution in practice.
22. What is the significance of NP-completeness in real-world applications? Discuss how the
NP-complete nature of problems like TSP and Vertex Cover affects practical decision-
making and computational limits.