Professional Documents
Culture Documents
Question Bank
Name of Subject :
Objective Questions
1. Define the term : Algorithm
2. What is the average case time complexity of bubble sort?
3. State true or false: “Dynamic Programming always leads to an optimal solution.”
4. Define the term : Directed Graph
5. Give any two sorting methods which are based on divide and conquer strategy.
6. What is the basic nature of greedy strategy?
7. What is meant by dead nodes in backtracking?
8. Write any one application of string matching.
9. State true or false: “Hamiltonian Problem is an example of NP-complete.” - True
10. Write the objective of making a change problem.
11. State true or false: “Prim’s algorithm is based on greedy strategy.” - True
12. What is meant by an optimal solution for a given problem?
13. Time complexity of is in linear time.
(a) Bubble (c) Shell sort
sort (b) Radix (d) Selection sort
sort
14. Which of the following cases does not exist in complexity theory of an algorithm?
(a) Average (c) Best
case case (d)
(b) Worst case Null case
15. Which of these is the Worst-case time complexity of Quick Sort - and cannot be expressed in lower
order terms?
(a) O(n) (d) O(n3)
(b) O(n log (e) O(log n)
n) (c) O(n2)
16. Which of these is the worst case time complexity of Merge Sort - and cannot be expressed in
lower order terms?
(a) O(n) (d) O(n3)
(b) O(n log (e) O(log n)
n)
(c) O(n2)
17. Which of these is the average case time complexity of Merge Sort - and cannot be expressed
in lower order terms?
(a) O(n) (d) O(n3)
(b) O(n log (e) O(log n)
n)
(c) O(n2)
18. Which of these is the time complexity involved in building a heap of n elements - and
cannot beexpressed in lower order terms?
(a) O(n) (d) O(n3)
(b) O(n log (e) O(log n)
n)
(c) O(n2)
19. A heap is a particular kind of a binary search tree. This statement is:
(a) True (b) False
20. The Floyd-Warshall all-pairs shortest path algorithm for finding the shortest distances between
nodes in a graph is an example of:
(a) A Dynamic Programming formulation.
(b) A Greedy Algorithm
(c) A recursion based divide and conquer technique.
21. A bitwise operation 'f' has an interesting characteristic, such that, if f(a,b) = c, it always turns
out to be the case that f(b,a) = c; f(a,c) = b; f(c,a) = b; f(b,c) = a; f(c,b) = a. Which of these
functions could 'f' possibly be?
(a) f(a,b) = a XOR (c) f(a,b) = a - b
b(b) f(a,b) = a + b (d) f(a,b) = a * b
Question Bank Analysis and Design of Algorithms
(Where a and b are the binary representations of any two non-negative integers)
22. A union find data-structure is commonly applied while implementing:
(a) A depth-first search traversal of a graph.
(b) A breadth-first search traversal of a graph.
Question Bank Analysis and Design of Algorithms
(c) Computing the minimum spanning tree of a graph using the Kruskal algorithm.
(d) Computing the all-pairs shortest path in a graph.
23. Which of these is the worst case time complexity for looking up a key in a binary search
tree - and cannot be expressed in lower order terms?
(a) O(n) (d) O(n3)
(b) O(n log (e) O(log
n) n)
(c) O(n )
2
24. The graph algorithm which forms an essential component of the 'make' or 'ant build' used by
programmers and software developers is:
(a) Shortest path algorithm
(b) Minimum spanning tree algorithm
(c) Bipartite matching
(d) Topological sort
3 | Page
Question Bank Analysis and Design of Algorithms
Numerical/Derivable
4 | Page
Question Bank Analysis and Design of Algorithms
Analysis of Algorithm
Theory
1. Explain why analysis of algorithms is important? Explain: Worst Case, Best Case &
Average Case Complexity.
2. Why do we use asymptotic notations in the study of algorithms? Explain different asymptotic
notations in brief.
3. What is an amortized analysis? Explain aggregate method of amortized analysis using suitable
examples.
4. Explain Selection Sort Algorithm and give its best case, worst case and average case complexity.
5. Explain Bubble sort algorithm. Derive the algorithmic complexity in Best case, worst case and
Average case analysis.
6. Write an algorithm for insertion sort. Analyse insertion sort algorithm for best case and worst case.
Numerical/Derivable
1. Let f(n) and g(n) be asymptotically positive functions. Prove or disprove the
following. a. f(n) + g(n) = Θ(min(f(n), g(n))).
2. Answer following
a. Prove that (n + a)b = Ө( nb) , b>0
b. Find big oh(Ο) notation for
following: i. f(n) = 6993
ii. f(n) = 6n2 + 135
c. Find big theta(Ө) and big omega(Ω)
notation. i. f(n) = 14 * 7 + 83.
ii. f(n) = 83n3 + 84n
d. Is 2n+1 = Ο(2n) ?
Explain.
3. Arrange the following rate of growth in increasing order.
● n3, 1, n2, nlogn, n2logn, logn), n0.5, n!, 2n
4. Explain master theorem and solve the following recurrence equation with master
method a. T(n)= 9T(n/3) + n
b. T(n)= 3T(n/4) + nlgn
5. Calculate computation time for the statement t3 in the following code fragment?
for i = 1 to n
{
for j = 1 to i
{
c = c + 1............................... t3
}
}
Prove that T(n) = 1+2+3+….+n = Θ(n2)
5 | Page
Question Bank Analysis and Design of Algorithms
1. Explain how multiplication of large integers can be done efficiently by using divide and
conquer technique?
2. Explain Binary search using divide and conquer method and compute its worst case running
time.
3. What is Divide and Conquer Technique? Explain in brief.
4. Design and analyze a quick sort algorithm using divide and conquer technique.
5. Analyse quick sort algorithm for best case, average case and worst case with example. In
which case it performs similar to selection sort?
6. Explain Strasson’s algorithm for matrix multiplication.
7. Discuss matrix multiplication problem using divide and conquer technique..
Numerical/Derivable
1. Sort the letters of word “DESIGN” in alphabetical order using Bubble sort.
2. Sort the letters of word “EXAMPLE” in alphabetical order using Selection sort.
3. Sort the letters of word “EDUCATION” in alphabetical order using Insertion sort.
4. Sort the following with Heap Sort Method .
a. 20, 50, 30, 75, 90, 60, 25, 10, 40
b. 65, 77, 5, 25, 32, 45, 99, 83, 69, 81
c. 65, 75, 5, 55, 25, 30, 90, 45, 80
5. Sort following with the Counting Sort
Method. a. 2, 5, 0, 3, 2, 3, 0, 3
6. Sort following with Bucket Sort
Method. a. 329, 457, 657, 839, 436, 720,
355
7. Sort following with Radix Sort
Method. a. 78, 17, 39, 26, 72, 94, 21,
12, 23, 68
8. Sort following with Shell Sort Method.
a. 62, 83, 18, 53, 07, 17, 95, 86, 47, 69, 25, 28
9. Sort the following using the Quick sort
algorithm. a. 50, 40, 20, 60, 80, 100, 45, 70, 105,
30, 90, 75
b. 4, 3, 1, 9, 8, 2, 4, 7
6 | Page
Question Bank Analysis and Design of Algorithms
Dynamic Programming
Theory
Numerical/Derivable
1. Consider the chain of matrices A1, A2 ... A6 with the dimensions given below. Give the optimal
parenthesization to get the product A2...A5
2. Using algorithm find an optimal parenthesization of a matrix chain product whose sequence
of dimension is ﴾5, 10, 3, 12, 5, 50, 6﴿ (use dynamic programming).
3. Generate equation for Matrix chain multiplication using Dynamic programming. Find out
minimum number of multiplications required for multiplying:
4. A [1 × 5], B [5 × 4], C [4 × 3], D [3 × 2], and E [2 × 1].
5. Given the four matrix find out optimal sequence for multiplication D=<5,4,6,2,7>
6. Given the four matrix find out optimal sequence for multiplication D=<15,5,10,20,25>
7. Using algorithm find an optimal parenthesization of a matrix chain product whose sequence of
dimension is ﴾13, 5, 89, 3, 34﴿ (use dynamic programming).
8. Solve a Making Change problem using Dynamic Programming. Give your answer for making
change of Rs. 8. (Denominations: d1=1, d2=4, d3=6).
9. Give optimal substructure for a make change problem. Consider an instance of such a
problem with coins 1, 4 and 6 units. Illustrate its solutions using a dynamic programming
approach involving a payment of 8 units or less.
10. Given coins of denominations 2, 4 and 5 with the amount to be paid is 7. Find optimal no. of coins
and sequence of coins used to pay a given amount using a dynamic method.
11. Given coins of denominations 1, 3 and 4 with the amount to be paid is 7. Find optimal no. of coins
and sequence of coins used to pay a given amount using a dynamic method.
12. Using algorithm determine an Longest Common Sequence of ﴾A,B,C,D,B,A,C,D,F ﴿ and
﴾C,B,A,F﴿ (use dynamic programming).
13. Find Longest Common Subsequence using Dynamic Programming Technique with
illustration X={A,B,C,B,D,A,B} Y={B,D,C,A,B,A}
14. Given two sequences of characters, P=<MLNOM> Q=<MNOM> Obtain the longest common
subsequence.
15. Given two sequences of characters, P=<ABCDABE>, Q=<CABE > Obtain the longest common
subsequence.
7 | Page
Question Bank Analysis and Design of Algorithms
16. Given two sequences of characters, P=<XYZYTXY> Q=<YTZXYX> Obtain the longest
common subsequence.
17. Find any one Longest Common Subsequence of given two strings using Dynamic
Programming. S1=abbacdcba S2=bcdbbcaac
18. Find the longest common subsequence for the given two sequences of
characters: P = (1,0,0,1,0,1,1,0,1,1,0,1); Q= ( 0,1,1,0)
19. Solve the following 0/1 Knapsack Problem using Dynamic Programming. There are five
items whose weights and values are given in the following arrays.
Weight w[] = { 1,2,5,6,7 }, Value v[] = { 1,6,18, 22, 28 }
20. Solve the following knapsack problem using a dynamic programming algorithm with given
capacity W=5, Weight and Value are as follows: (2, 12), (1, 10), (3, 20), (2, 15).
21. Solve the following 0/1 Knapsack Problem using Dynamic Programming Method. Write the
equation for solving the problem.
8 | Page
Question Bank Analysis and Design of Algorithms
Greedy Algorithm
Theory
Numerical/Derivable
1. Consider the following undirected weighted graph. Find a minimum spanning tree for the
same using Kruskal’s algorithm.
2. Mention applications of a minimum spanning tree. Generate a minimum spanning tree from the
following graph using Prim’s algorithm. (Start at vertex a)
9 | Page
Question Bank Analysis and Design of Algorithms
5. Using greedy algorithm find an optimal solution for knapsack instance n=7, M = 15
(P1,P2,P3,P4,P5,P6,P7)=(10,5,15,7,6,18,3) and (w1,w2,w3,w4,w5,w6,w7) = (2,3,5,7,1,4,1)
6. Generate minimum spanning tree of fig. A using Prim’s algorithm.
7. Generate minimum spanning tree of fig. A using Kruskal’s algorithm.
8. Find Minimum Spanning Tree for the given graph using Prim’s Algo. (initialization from node
A)
9. Following are the details of various jobs to be scheduled on multiple processors such that no two
processes execute at the same time on the same processor. Show schedule of these jobs on a
minimum number of processors using greedy approach.
10 | Page
Question Bank Analysis and Design of Algorithms
Exploring Graphs
Theory
Numerical/Derivable
11 | Page
Question Bank Analysis and Design of Algorithms
Numerical/Derivable
12 | Page
Question Bank Analysis and Design of Algorithms
String Matching
Theory
1. Explain with example: The naïve string matching algorithm. Also give its time complexity.
2. Explain the Rabin-Karp method for string matching and also give the algorithm and its time
complexity.
3. Define Finite Automata? Explain its use for string matching with illustration.
Numerical/Derivable
1. Explain spurious hits in the Rabin-Karp string matching algorithm with examples. Working
modulo q=13, how many spurious hits does the Rabin-Karp matcher encounter in the text T =
2359023141526739921 when looking for the pattern P = 31415?
13 | Page
Question Bank Analysis and Design of Algorithms
Introduction to NP-Completeness
Theory
Numerical/Derivable
14 | Page