DAA Question Bank
DAA Question Bank
(Question Bank)
Unit – 1
1. What is Recursion and Recurrence relation?
2. What is an Algorithm and explain briefly about time and space complexities?
3. How do you compare the performance of various algorithms? Explain
4. Write down all the cases in Master’s Theorem.
5. What is recurrence relation? Draw the recurrence tree for T(n) = 2T(n/2) + c and derive time
complexity from that recurrence tree.
6. What is meant by base case and recurrence relation? Is Master’s theorem can be used to find
time complexity of any algorithm? If Not, how can you find time complexity of that
algorithm.
7. How to analyse a recursion program? Find time complexity of binary search algorithm using
master’s theorem.
8. Describe Asymptotic Notations in Detail
Unit – 2
1. Explain Binary Search and its Complexity in detail along with Code
2. Explain Merge Sort with an example along with its complexities
3. Sort the list 415, 213, 700, 515, 712, 715 using Merge sort algorithm. Also explain the time
complexity of merge sort algorithm.
4. Discuss the strassen’s matrix multiplication algorithm in detail. Explain how the efficiency
achieved through this algorithm.
5. Explain Selection sort?
6. Explain Quick Sort in Detail along with the Time and Space Complexities with an Example
7. Perform Strassen’s matrix multiplication on a 2*2 matrix?
Unit – 3
1. Given a graph and a source vertex in the graph, find the shortest paths from the source to
all vertices in the given graph.
2. Given the following graph G, Convert the given graph G into minimum Spanning Tree using
Prims Algorithm
3. Define spanning tree. Write Kruskal’s algorithm for finding minimum cost spanning tree.
Describe how Kruskal’s algorithm is different from Prim’s algorithm for finding minimum
cost spanning tree.
4. Construct the Huffman tree for the string “HELLOWORLD”. How Huffman code varies from
fixed length code?
Unit – 4
1. Solve the Following Knapsack Problem using Dynamic Programming. The Capacity of the
knapsack is 5 and number of items are 4
Weights Values
2 3
3 4
4 5
5 6
2. Given two strings text1 and text2, return the length of their longest common subsequence. If
there is no common subsequence, return 0. Write the Code along with its Time and Space
Complexity using Dynamic Programming.
Example 1:
Input: text1 = "abcde", text2 = "ace"
Output: 3
Explanation: The longest common subsequence is "ace" and its length is 3.
3. What is dynamic programming? Explain how coin change problem is working based on
dynamic programming with an example.
4. What is the difference between Dijkstra’s algorithm and Floyd Warshall algorithm? Explain
Floyd-Warshall algorithm with an example.
5. What do you mean by Dynamic programming? How can you differentiate greedy algorithm
and dynamic programming?
Unit – 5
1. Sort the Digraph for Topological Sort using DFS Algorithm
3. What are the representations of a graph? Write down the advantages and disadvantages of two
representations of a graph.
4. What are the data structures used in DFS and BFS? Explain the working principle and back
tracking in DFS by taking appropriate example.
5. Write a pseudo code for Breadth First Search (BFS) with illustrations?
Unit – 6
1. The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no
two queens attack each other.
Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the
answer in any order.
Each solution contains a distinct board configuration of the n-queens' placement, where 'Q'
and '.' both indicate a queen and an empty space, respectively.
3. Explain how back tracking is used in N-Queen problem using Tree diagram for 4-Queen
problem.
Unit – 7
1. Explain the classes of P and NP in detail.
2. The minimum number of arithmetic operations required to evaluate the polynomial P(X) =
X5 + 4X3 + 6X + 5 for a given value of X using only one temporary variable are?