0% found this document useful (0 votes)
326 views10 pages

DAA Question Bank

The document contains questions related to algorithms and data structures. It covers topics like matrix multiplication, asymptotic notations, analysis of algorithms, graph representations, minimum spanning trees, dynamic programming, greedy algorithms, and NP-complete problems. Some questions ask to analyze time complexity, solve recurrence relations, implement sorting and searching algorithms, and find optimal solutions to problems like shortest paths, knapsack, and job scheduling.

Uploaded by

AVANTHIKA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
326 views10 pages

DAA Question Bank

The document contains questions related to algorithms and data structures. It covers topics like matrix multiplication, asymptotic notations, analysis of algorithms, graph representations, minimum spanning trees, dynamic programming, greedy algorithms, and NP-complete problems. Some questions ask to analyze time complexity, solve recurrence relations, implement sorting and searching algorithms, and find optimal solutions to problems like shortest paths, knapsack, and job scheduling.

Uploaded by

AVANTHIKA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

STANLEY COLLEGE OF ENGINEERING & TECHNOLOGY FOR WOMEN

(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”);
}

9. What is the running time of the following algorithm:


Algorithm A()
{
int i, j, k, n;
for( i = 1 to b) do: for(
j = 1 to n) do: for( k =
1 to 100) do:
print(“Hi”);
}

10. Difference between priori analysis and posterior analysis?


11.What are Dictionaries? Explain?
12. Define DFS with example?
13. Explain different graph and tree representations.
14. Define minimum spanning tree. Draw the spanning tree of the given graph
16.Define Big Oh and Big Omega notations of time complexity analysis. Express Big Oh and Big
Omega for the following algorithm
Algorithm search (a, k)
//a : array of n elements
//k : element to be searched in the array
{for I : = 1 to n do
{if (a [i] ==k)
return k; }
return – 1; }

17. Write Weighing Union algorithm?


18. 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


19. What do you analyze in an algorithm? What is the basis of analysis?

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

4. Apply quicksort and mergesort to sort the list E, X, A, M, P , L, E in alphabetical


order.
5. Draw the tree of the recursive calls made. Compare their complexities?
6. Can you design a more efficient algorithm than the one based on the brute force strategy to
solve the closest-pair problem for n points x1, x2,...,xn on the real line?
7. Implementing the following in the language of your choice.
Quick sort
Merge sort
Binary search
run the program on inputs n=100,200 & 500 to verify the algorithm efficiency. Note the time complexities
and analyze the performance?
8. Apply dynamic programming to obtain optimal binary search tree for the identifier set (a1, a2,
a3,a4)=(cin, for, int, while) with (p1, p2, p3, p4)=(1, 4, 2, 1), (q0, q1, q2, q3, q4)=(4, 2, 4, 1, 1) and also write
algorithm for its construction.
9. Trace the quick sort algorithm to sort the list C, O, L, L, E, G, E in alphabetical order.
10.a) Discuss how quick sort works to sort an array and trace the dataset 65, 70, 75, 80, 85 60, 55, 50 45.
Draw the trees of recursive calls made.
UNIT III

Short Questions:

1. Write control abstraction of greedy method?

2. Define minimum cost spanning tree?

3. What is principle of optimality?

4. Write Control abstraction of Dynamic Programming?

5. Define Knapsack Problem?

6. Write about Optimal Binary Search Tree?

7. Write an Algorithm for 0/1 Knapsack problem using Dynamic programming?

8. State different Algorithms for Minimum Cost Spanning Trees?

9. Discuss in details about the problem of job sequencing with deadlines.

10. Explain Dominance rules in 0/1 Knapsack Problem.

11. State the principal of optimality.


12. Write about principle of optimality in shortest path problem
13. Explain feasible solution, optimal solution and objective functions with example.

Long Questions:

1. a) What is single source shortest path problem. Explain with an example.


b) Define Spanning tree and explain KruskalÄs algorithm for finding minimum cost spanning tree for
the given graph.

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.

16. Job sequencing with deadlines using Greedy Approach.


17. Write in detail with an example the Dijkstra’s algorithm for shortest path in a graph.

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. Write the applications of Branch and Bound problem.


2. List the applications of backtracking
3. What is pruning in backtracking?
4. Differentiate between Backtracking and Branch and Bound approaches
5. What is Hamiltonian cycle? How is it different from the tour of travelling salesperson problem?
6. Explain what are explicit and implicit constraints of 8-Queens problem?
7. Explain travelling salesperson problem?
8. What is Hamiltonian cycle?
9. Difference between dynamic programming and Gready method.
10. Difference between Backtracking and branch and bound
11. Differentiate LIFO and FIFO branch and bound techniques.
12. Write Recursive backtracking algorithm?
13. Write Iterative backtracking method?
14. Define Hamiltonian Cycle?
15. Write Control abstraction for Least Cost Search?
16. Types of Branch and Bound?
Long 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.

6. Find an optimal solution to 0/1 knapsack using LCBB when


P: {20, 30, 35, 12, 3}, w: {2, 5, 7, 3, 1}, Knapsack capacity, m:19.
7. 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).
8. Use Optimal binary search tree algorithm and compute wij, cij, rij,
0<=i<=j<=4,p1=1/10,p2=1/5,p3=1/10.p4=1/20.q0=1/5,q1=1/10,q2=1/5,q3=1/20,q4=1/20
9. Solve the following instance of travelling salesperson problem using Least Cost
Branch Bound.

10. Define Hamiltonian Cycle? Find all the Hamiltonian Cycles of Given Graph using
Backtracking?

11. Find the Hamiltonian circuits of a given graph using Backtracking

12.Solve Travelling Salesman Problem using Branch and Bound

12. Solve Travelling Salesman Problem using Branch & Bound


UNIT V
Short Questions:
1.Distinguish between deterministic and non deterministic algorithm.
2.What is meant by Satisfiability?
3.State Cook’s theorem. Explain its significance in NP – complete theory
4.Define Tries and Types of Tries?
5.Define String and String Operations?
6.Explain what are NP-Hard and NP-Complete problems.
7.Whats the use of Huffman coding?
8. Write Applications of Tries?
9. Write Applications of Pattern Matching Algorithms?
10. Applications of NP-Complete and NP-Hard Problems?
Long Questions:

1. Explain NP-Hard Scheduling Problems.


2. Explain P, NP, NP-Complete and NP-Hard Problems with two examples for each class of
problems.
3. Discuss P, NP class of problems. Write non deterministic algorithm for sorting?

b. Discuss any two NP-Hard graph problems


4. Construct a Huffman code for the following data:

Encode ABACABAD using the code of question.

Decode 100010111001010 using the code of question.

4. Explain Brute Force Pattern Matching with Example?


5. Explain Boyer-Moore Algorithm with Example?
6. Explain Approximation Algorithms?
7. Implement Huffman Coding Algorithm on String.

8. Implement Huffman Coding Algorithm on String?

abbcdbccdaabbeeebeab

9. Implement Huffman Coding Algorithm?


character Frequency
a 5
b 9
c 12
d 13
e 16
f 45

10. Apply Brute Force Algorithm for pattern matching


String: NOBODY NOTICED HIM
Pattern: NOT
String: a c a a b c a c a a b c
Pattern: a a b
11. Implement Boyer-Moore Algorithm on String

1. Bad Character Heuristics


2. Good Suffix Heuristics

EX1: T: N Y O O N O Y O O

P: N O Y O

EX2: Txt[] = "THIS IS A TEST TEXT"


pat[] = "TEST"
EX3: txt[] = "AABAACAADAABAABA"
pat[] = "AABA"
EX4: T: G C A A T G C C T A T G T G A C C
P: T A T G T G
12. Write Approximation Algorithm?

You might also like