1.
Algorithm Design Techniques:
Q1. Explain the divide-and-conquer paradigm. Describe the Merge Sort algorithm and
analyze its time complexity using the Master Theorem.
Q2. Compare and contrast the Greedy and Dynamic Programming approaches. Provide an
example of a problem solved by each approach, and explain why one is more suitable than
the other.
Q3. Explain the Backtracking technique. Write a backtracking algorithm for solving the N-
Queens problem, and analyze its time complexity.
Q4. What is the difference between a "brute force" algorithm and an optimized algorithm?
Give an example of a problem where brute force is used and where optimization improves
performance.
2. Sorting and Searching Algorithms:
Q5. Implement and analyze the time complexity of QuickSort. What are the best, worst, and
average case complexities, and how does the choice of pivot affect performance?
Q6. Explain the concept of Heap Sort. Show how to build a max heap and use it to sort an
array. What is the time complexity of Heap Sort?
Q7. Compare the time complexities of Merge Sort and QuickSort. In what scenarios would
Merge Sort be preferred over QuickSort and vice versa?
Q8. Describe the Binary Search algorithm. How does it work, and what is its time
complexity? Can you use Binary Search in a non-sorted array? If not, why?
3. Graph Algorithms:
Q9. Explain Dijkstra’s algorithm for finding the shortest path in a graph. What are its time and
space complexities? Discuss how the algorithm behaves when there are negative edge
weights.
Q10. Describe the depth-first search (DFS) and breadth-first search (BFS) algorithms.
Compare and contrast these two algorithms in terms of their time complexity, space
complexity, and use cases.
Q11. Write an algorithm to find the Minimum Spanning Tree (MST) using Prim’s algorithm.
Analyze the time complexity of your solution.
Q12. What is the Floyd-Warshall algorithm? Explain how it finds the shortest paths between
all pairs of nodes in a graph and analyze its time complexity.
4. Dynamic Programming (DP):
Q13. Solve the following problem using Dynamic Programming: Given a set of items, each
with a weight and a value, determine the maximum value that can be obtained by selecting a
subset of items that fit within a given weight limit. (0/1 Knapsack problem)
Q14. What is the Longest Common Subsequence (LCS) problem? Write a dynamic
programming solution to find the LCS of two strings, and explain the time complexity of your
algorithm.
Q15. Solve the Matrix Chain Multiplication problem using Dynamic Programming. Explain the
solution step by step, and provide the time complexity.
5. NP-Hard and NP-Complete Problems:
Q16. What is the difference between NP, NP-Complete, and NP-Hard problems? Provide an
example of each type of problem.
Q17. Discuss the Traveling Salesman Problem (TSP). Is it NP-Hard or NP-Complete? Describe
one of the approximate solutions to this problem.
Q18. What is the Knapsack problem, and why is it NP-Hard? Show how the problem can be
solved using Dynamic Programming for the 0/1 Knapsack case.
6. Advanced Topics and Miscellaneous:
Q19. What is the time complexity of the following recurrence relation? Solve using the
Master Theorem or Recursion Tree:
T(n)=2T(n/2)+O(n)T(n) = 2T(n/2) + O(n)
Q20. Discuss the concept of Memoization and Tabulation in Dynamic Programming. Provide
examples of problems where each technique would be applied and explain the benefits.
Q21. Write an algorithm to detect a cycle in a directed graph using topological sorting and
analyze its time complexity.
Q22. Describe the Kruskal’s Algorithm for finding the Minimum Spanning Tree. What is the
time complexity, and how does it differ from Prim’s algorithm?
7. Computational Complexity and Analysis:
Q23. Explain Big O, Big Theta, and Big Omega notations. How do they differ, and when do
you use each one? Provide examples.
Q24. Given the following recursive function, determine its time complexity using the
Recursion Tree method:
T(n)=T(n−1)+O(n)T(n) = T(n-1) + O(n)
Q25. Prove that Merge Sort runs in O(nlogn)O(n \log n) time using the Master Theorem.
8. Miscellaneous Algorithm Analysis:
Q26. Given a set of strings, write an algorithm to find the longest common prefix among
them. What is the time complexity of your solution?
Q27. Discuss the Fibonacci Sequence. Write both a recursive and a dynamic programming
solution for calculating the nth Fibonacci number and analyze the time complexity of each.
Q28. Given a binary tree, write an algorithm to find the diameter of the tree. Analyze the
time complexity of your solution.
9. String Algorithms:
Q29. Explain the Rabin-Karp algorithm for string matching. What is its time complexity, and
how does it handle multiple matches?
Q30. Solve the Pattern Matching Problem using the Knuth-Morris-Pratt (KMP) algorithm.
Provide both the algorithm and its analysis in terms of time complexity.