DAA - Question Bank
DAA - Question Bank
Branch : IT Sem : IV
Question Bank
Module I
Define algorithm. Also explain the criterion every algorithm must satisfy.
Define and explain the asymptotic notations Big “Oh” and Omega ( Ω ) and Theta (Ɵ).
Define Time and Space complexity. Also find the asymptotic time complexity of the
following algorithm.
for i:= 0 to n-1 do
statement 1;
for i:=0 to n-1 do
for j:= 0 to n-1 do
statement 2; Similar…
State Masters Theorem for dividing functions. Also find out the time complexity for the following
recurrence relation.
. Similar…
State Masters Theorem for decreasing functions. Also find out the time complexity for the following
recurrence relation.
T(n) = 2T(n-2) + 1 Similar…
Using substitution method, and not otherwise, find the time complexity of the following
algorithm.
Algorithm Test(n)
{
if (n > 0)
for(i:=0; i<n; i:=i+1)
print i;
Test(n-1);
} Similar…
Module II
Divide & Conquer
Write and explain the control abstraction of divide-and-conquer strategy along with it’s both
recurrence relation.
Write an algorithm to sort the elements using Merge sort technique. Find it’s time complexity
with its recurrence relation and not otherwise.
Sort the following numbers in steps as it applied by using Merge sort technique.
[310 285 179 652 351 423 861 254 450 520] Similar…
Define Binary search problem. Also write recursive algorithm for binary search and find its
best, average, worst case time complexity by writing its recurrence relation.
Define Binary search problem. Also write iterative algorithm for binary search and find its
best, average, worst case time complexity.
Let a = [-15, -6, 0, 7, 9, 23, 54, 82, 101, 112, 125, 131, 142, 151]. Find the number of
comparisons required to search x= 151, & x= -14 by using binary search method. Also
comment on maximum number of comparisons required in case of all successful and all
unsuccessful searches.
Write an recursive algorithm for finding maximum and minimum item in a set of n elements
that uses divide and conquer design strategy. Write its recurrence relation and in turn find
maximum number of element comparison required.
Show that Strassen’s matrix algorithm requires 7 multiplications and 18 additions / subtractions. Also
write its recurrence relation.
Write a detailed note on Strassen’s matrix algorithm.
Greedy Method
Write and explain the control abstraction of Greedy Method.
Explain the Knapsack problem. Write the algorithm to solve the knapsack problem
Using greedy approach. Also solve the given instance of the Knapsack problem: m = 15,
n=7, (p1, p2, ….,,p7) = (10, 5, 15, 7, 6, 18, 3) and (w1, w2, …,w7) = (2, 3, 5, 7, 1, 4, 1).
Similar…
Write Greedy algorithm for Knapsack problem. Also solve following Knapsack problem by greedy
method. m = 12, n = 4, profits (p1, p2, p3, p4) = ( 15, 20, 30, 50), and weights (w1, w2, w3, w4) = (3,
2, 8, 4). Similar…
Write an algorithm to solve the JSWD problem using greedy method and comment on its
time complexity. Also solve the JSWD problem instance : Let n=4, (p1 , p2 , p3 ) = (100, 10,
15, 27) and (d1 , d2 , d3 ) = (2, 1, 2, 1). Similar…
Write an algorithm for Faster Job Sequencing (FJS) and find it’s computational
complexity. Using this algorithm find the optimal processing sequence and the total
profit earned for the given instance: Number of jobs, n=5, Profits earned (p1, p2, p3,
p4, p5) = ( 88, 79, 42, 38, 25), Deadlines (d1, d2, d3, d4, d5) = (2, 2, 1, 3, 3). Similar…
What is Optimal Storage on Tape problem. Write an algorithm to solve Optimal storage on
Tapes for multiple tapes. Find all the permutations of programs and find optimal solution
(minimum MRT) Example: Let n = 3 and (l1, l2, l3) =(5, 10, 3). Similar…
Find optimal solution and minimum retrieval time for Optimal Storage on Tape problem
Example: Let n = 3 and (l1, l2, l3) =(5, 10, 3). Similar…
Find optimal placements for 13 programs on three tapes T1, T2, T3 where the
programs are of lengths (12, 5, 8, 32, 7, 5, 18, 26, 4, 3, 11, 10, 6). Similar…
Dynamic Programming
State the Principle of Optimality. Also write the difference between greedy and dynamic
strategy.
Write an algorithm for multistage graph using Forward approach. Also find the shortest path between
vertex 1 and 6 of the following graph using the same.
2
2 4
3 1 6
1 4 6
5 7
3 5
2 Similar…
Write an algorithm for multistage graph using backward approach. Also find the shortest path
between vertex 1 and 12 of the following graph using the same.
Similar…
What is 0/1 Knapsack problem? Solve the 0/1 Knapsack problem using dynamic
programming approach for the instance : n =3, (w1 , w2 , w3) = (2, 3, 4) & (p1 , p2 , p3) = (1,
2, 5) , m= 6. {by Formula/Tabular/Set method} Similar…
State the Dominance rule. Also solve 0/1 Knapsack problem using set method : n =3, (w1 ,
w2 , w3) = (2, 3, 4) & (p1 , p2 , p3) = (1, 2, 5) , m= 6. Similar…
What is travelling salesperson problem? Consider the directed weighted graph shown below..
The edge lengths are given by matrix.. Find the optimal tour for this graph with its length.
Similar…
Explain in short Traveling Salesperson Problem (TSP). Also list out any three applications of TSP.
Backtracking
Explain the backtracking algorithmic design strategy with generalised recursive backtracking
algorithm. (Control Abstraction)
Explain the backtracking algorithmic design strategy with an iterative backtracking
algorithm. (Control Abstraction)
State the sum-of-subset problem. Let w[1:6] = [5, 10, 12, 13, 15, 18] and M= 30. Find
any two possible subsets of w that sum to M by drawing the portion of the state space
tree. Similar…
Write an algorithm for sum of subsets problem. Also comment on time complexity of the
same.
Explain N-queens problem in short. Also write the algorithms NQueens( ) and Place( ) to solve the
N-Queens problem.
Explain N-Queens problem in detail. Also solve N-Queens problem using state space tree foe
n=4. (At least one solution.)
Explain Graph Coloring problem in short. Also write the algorithms mColoring( ) and NextValue( )
to color the given graph.
Find all 3-coloring combinations for the following graph shown in fig a. with the help of state space
tree & not otherwise which selects color G for vertex 1. [Three colors available are {R G B}]
Similar…
How 0/1 Knapsack problem can be solved using Backtracking design strategy? Consider the
instance of the 0/1 Knapsack problem : n= 8 p=(11, 21, 31, 33, 43, 53, 55, 65), w=(1, 11, 21,
23, 33, 43, 45, 55) , m= 110. Find all the solutions/ at least one solution. Similar…
Write the algorithm BKnap() and Bound to solve 0/1 Knapsack problem using Backtracking
approach.
What is Least Cost (LC) Search method? Write the algorithm for LC Search. Write
and explain its properties with suitable example.
Explain the method FOFO branch and bound. Also draw the state space tree to solve JSWD problem
with n= 4. (Variable tuple-size solution)
Explain the method LIFO branch and bound. Also draw the state space tree to solve JSWD problem
with n= 4. (Variable tuple-size solution)
Solve the JSWD problem for the instance: Let n=4, (p1 , p2 , p3 , p4 ) = (5, 10, 6, 3), (d1 , d2 , d3
, d4 ) = (1, 3, 2, 1) and (t1 , t2 , t3 , t4 ) = (1, 2, 1,1). Find optimal solution using variable tuple
size FIFO B&B. Similar…
Solve the JSWD problem for the instance: Let n=4, (p1 , p2 , p3 , p4 ) = (5, 10, 6, 3), (d1 , d2 , d3
, d4 ) = (1, 3, 2, 1) and (t1 , t2 , t3 , t4 ) = (1, 2, 1,1). Find optimal solution using variable tuple
size LIFO B&B. Similar…
Solve the JSWD problem for the instance: Let n=4, (p1 , p2 , p3 , p4 ) = (5, 10, 6, 3), (d1 , d2 , d3
, d4 ) = (1, 3, 2, 1) and (t1 , t2 , t3 , t4 ) = (1, 2, 1,1). Find optimal solution using variable tuple
size Least-cost B&B. Similar…
Solve the 0/1 Knapsack problem using LC B & B approach for the instance : n =4, (w1 , w2 ,
w3 , w4) = (2, 4, 6, 9), (p1 , p2 , p3 , p4) = (10, 10, 12, 18) , & m= 15. Similar…
Solve the 0/1 Knapsack problem using FIFO B & B approach for the instance : n =4, (w1 , w2
, w3 , w4) = (2, 4, 6, 9), (p1 , p2 , p3 , p4) = (10, 10, 12, 18) , & m= 15. Similar…
Solve the 0/1 Knapsack problem using LIFO B & B approach for the instance : n =4, (w1 , w2
, w3 , w4) = (2, 4, 6, 9), (p1 , p2 , p3 , p4) = (10, 10, 12, 18) , & m= 15. Similar…
Write the generalised algorithm to solve the Travelling Salesperson problem using B&B.
Module III
What are different Graph representation schemes? Explain any one with suitable example.
Write the algorithm for Breadth-first-search (BFS) / Breadth- first Traversal (BFT) algorithm
of a graph. Explain it in brief.
Write the algorithm for Depth-first-search (DFS) / Depth- first Traversal (DFT) algorithm of a graph.
Explain it in brief.
Define Spanning Tree & MST. Write the Prim’s algorithm to find the MST and find the time
complexity of it.
Define Spanning Tree & MST. Write the Kruskals’s algorithm to find the MST and find the
time complexity of it.
Define minimum spanning tree? Using the Prim's algorithm and not otherwise find the
minimum spanning tree and minimum cost for the following undirected graph example.
Similar…
Define minimum spanning tree? Using the Kruskal's algorithm and not otherwise find the
minimum spanning tree and minimum cost for the following undirected graph example.
Similar…
Write an algorithm for finding single-source shortest Path (Dijkstra's algorithm). Also find shortest
paths from the starting vertex V0 to all other vertices’ for the following directed graph. Similar…
Write an algorithm for finding All-Pairs shortest Path (Floyd Warshal algorithm. Also find the all
pairs shortest path for the following directed graph. Similar…
Module IV
Define class NP-Hard, and NP-complete problems. Also show the relation between them
diagrammatically.
Define class P problems & class NP problems. Also show diagrammatically the relation between class
P, NP, NP-Hard, and NP-complete.
Write Nondeterministic algorithm for searching and explain three new functions used in this
algorithm.
Write Nondeterministic algorithm for sorting and explain three new functions used in this
algorithm.