DAA Question Bank
DAA Question Bank
(AUTONOMOUS)
Department of AI&DS
Design and Analysis of Algorithms QUESTION
BANK
UNIT I
Short Questions:
1. Give the algorithm for matrix multiplication and find the time complexity of the algorithm using step –
count method.?
2. Explain in detail about algorithm specification and Performance analysis.
3. Explain about the space and time complexities of algorithms.
4. Define Algorithm. Write any four specifications of an algorithm?
5. Write and Explain Asymptotic Notations (O, Omega, Theta) or Define Big-oh and Big-Omega
notation.?
6. Write a short note on Practical complexities and Performance Measurements of algorithms with
examples.
7. Sketch the plot of functions showing the growth of functions
8. Analyze the performance of the following algorithm:
Algorithm A()
{
int i,j;
for( i = 1 to n) do:
for( j = 1 to n) do:
print(“Hi”);
}
= a T(n/b)+f(n) n > 1
Long Questions:
1. Consider the following 3 disjoint sets. S1 = {1,7,8,9}; S2 = {2,5,10}; S3 = {3,4,6}.
Represent these sets as trees and perform union on these sets?
2. Write the algorithms for UNION and FIND with an example?
3. Draw the worst case tree using weighing rule of union after implementing
the following set operations Union(1,2), Union(3,4), Union(5,6),
Union(7,8), Union(1,3), Union(5,7), Union(1,5)?
4. Express the following function in Big oh, omega and theta notations a) 4*2n b) 10logn+6
c) 10n2+5n?
5. Solve the recurrence relation T(n) = T(1) n = 1 = a T(n/b)+f(n) n > 1 for a, b=2,
T(1) = 2 and f(n) = n
6. State the weighting, collapsing rules in Sets?
7. Write about Weighing rule and Collapsing rule. Write an algorithm for union of
two sets using weighing rule?
8. Differentiate performance measurement and performance estimation of Algorithms.
b) Explain UNION and FIND, Write algorithms and examples.
9. Define Spanning tree and explain Kruskal’s algorithm for finding minimum cost spanning tree for the
given graph.
UNIT II
Short Questions:
1. Define control abstraction and computing time of the Divide and Conquer method.
2. Discuss the Binary Search algorithm and analyze its time complexity. List out any two
drawbacks of binary search.
3. List the differences between divide and conquer and Greedy method.
4. Analyze the computing time for Quick Sort. (Best, Worst, Average case time
complexities)
5. Write an algorithm for In-place partitioning of elements taking first element of the array
as the pivot element.
6. Explain Merge Sort with an example and also write the algorithm. List drawbacks of merge sort.
7. Write the differences between Merge sort and Quick sort with an example.
8. Discuss Closest-Pair and Convex-Hull Problems.
9. Write an algorithm for binary search using Divide-and-Conquer
10. Derive the best complexity of Merge Sort.
11. What is Hamiltonian cycle? How is it different from the tour of travelling salesperson problem? 12.
Write an algorithm for quick sort and derive the best case and worst case time complexities
13. What is Knapsack Problem?
Long Questions:
1. Sort the array {44, 33, 11, 55, 77, 90, 40, 60, 99, 22, 88} using Quick sort. Show each step?
2. Sort the array {14, 33, 27, 10, 35, 19, 42, 44} using Merge Sort. Show each step?
3. Explain the following Exhaustive search problem using brute force approach
1)Travelling Salesman Problem
2) Knapsack Problem
3) Assignment problem
Short Questions:
Long Questions:
2. Explain job sequencing with deadlines algorithm and also find the solution for the instance
n=7,(p1,p2,…p7)=(3,5,20,18,1,6,30) and (D1,D2,..,D7)= (1,3,4,3,2,1,2)?
3. Find the minimum cost spanning tree for the graph given below.
4. What is the optimal solution generated using greedy approach for job scheduling with deadlines when
n =7, (P1, P2, …, P7) = (3, 5, 20, 18, 1, 6, 30) and (d1, d2, ….,d7) = (1, 3, 4, 3, 2, 1, 2), where n
is number of jobs, Pi is profit of ith job, di is deadline of ith job.( i = 1 to 7)?
5. State Knapsack problem and explain a feasible solution and an optimal solution using
a suitable example. Find an optimal solution to the knapsack instance n=7, m=15,
(p1, p2, …,p7) = (10, 5, 15, 7, 6, 18, 3) and (w1, w2, …, w7) = (2, 3, 5, 7, 1, 4, 1).
6. (a)Write Kruskal’s algorithm to find the minimum cost spanning tree. Explain with an
example.
(b) Differentiate between greedy subset paradigm and ordering paradigm. State an
example in each case.
7. Write Prim’s algorithm to find the minimum cost spanning tree. Explain with an
example.
8. Find the minimum cost spanning tree using Kruskal’s and Prim’s algorithm for the
following graph.
10. Apply single source shortest path for the following graph
11. What is dynamic programming? List out any two problems addressed by
dynamic programming. State principle of Optimality.
12. Apply Floyd’s Warshall Algorithm to find the All-Pairs shortest paths for the Graph
shown in figure.
14. Using the algorithm OBST, compute W(i,j), R(i,j) and C(i,j), 0<=i<j<=4 for the
identifier set (a1,a2,a3,a4)=(end, goto, print, stop) with p(1)=1/20, p(2)=1/5, p(3)=1/10,
p(4)=1/20; q(0)=1/5, q(1)=1/10, q(2)=1/5, q(3)=1/20 and q(4)=1/20. Using the R(i,j)’s
construct the OBST?
15. What are greedy algorithms? What are their characteristics? Explain any greedy algorithm with
example.
16. Single source shortest path : Use Algorithm Shortest Paths to obtain in non-decreasing order
the lengths of the shortest paths from vertex 1 to all remaining vertices
15. Define spanning tree and explain Kruskal’s algorithm for finding MST of the graph using the graph
given below and write its time complexity.
18. For the identifier set (a1,a2,a3,a4)=(count, float, if, while) with P(1)=1/20, P(2)=1/5,
P(3)=1/10,P(4)=1/20,q(0)=1/5, q(1)=1/10, q(2)=1/5,q(3)=1/20, and q(4)=1/20
construct the OBST. (10M)
19. Write recurrence relations for solving OBST using dynamic programming and construct the tree for
given data:
N = 4, (a1, a2, a3, a4) = (end, got, print, stop)
P(1:4) = (1/20, 1/5, 1/10, 1/20) q(0:4) = (1/5, 1/10, 1/5, 1/20, 1/20)
UNIT IV
Short Questions:
1. What are Hamiltonian cycles? Present an algorithm that finds all the Hamiltonian cycles of a
given graph.
2. Write an algorithm for n Queens using backtracking approach
3. Give the formulation of modified knapsack problem using branch and bound and find the optimal
solution using least cost branch and bound with n=4, m=15, (p1…p4)=(15 15 17 23), (w1…w4)=(3
5 6 9).
4. Draw the portion of state space tree generated by LCBB by the following knapsack problem
n=5,(p1,p2,p3,p4,p5)=(10,15,6,8,4),(w1,w2,w3,w4,w5)=(4,6,3,4,2) and m=12.
5. Draw the portion of the state space generated by LCBB for the knapsack Instance.
n=4,(p1,p2,p3,p4)=(10,10,12,18),(w1,w2,w3,w4)=(2,4,6,9) and m=15.
10. Define Hamiltonian Cycle? Find all the Hamiltonian Cycles of Given Graph using
Backtracking?
abbcdbccdaabbeeebeab
EX1: T: N Y O O N O Y O O
P: N O Y O