You are on page 1of 15

Gujarat Technological University

C. K. Pithawalla College of Engineering and


Technology, Surat

Question Bank

Name of Subject :

Subject Code : 3150703

Subject coordinator : Prof. Nidhi Hadiya


Question Bank Analysis and Design of Algorithms

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

Basics of Algorithms and Mathematics


Theory

1. What is an algorithm? Explain various properties of an algorithm.


2. What is the relation? Explain equivalence relation.
3. Explain linear inequality and equations.
4. What is an algorithm? Explain characteristics of any algorithm.
5. Explain the following terms with an example. 1. Set 2. Relation 3. Function
6. Compare Iterative and Recursive algorithms to find out Fibonacci series.
7. Give the recursive algorithm to find the Fibonacci sequence. Comment on the complexity of the
algorithm.

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

Divide and Conquer Algorithm.


Theory

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

1. Define: Principle of Optimality. Optimal Substructure property


2. Define: Optimal Solution, Feasible solution.
3. Explain common characteristics of dynamic programming.
4. What is the Principle of Optimality? Explain its use in the Dynamic Programming Method.
5. Describe LCS problem with example and obtain optimal substructure required to solve it using
dynamic programming.
6. Describe an assembly line scheduling problem and give a dynamic programming algorithm to
solve it.

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

1. Explain in brief characteristics of greedy algorithms.


2. Explain Greedy method in detail with examples and differentiate it with a dynamic method.
3. Discuss and derive an equation for solving the 0/1 Knapsack problem using dynamic
programming methods. Design and analyse the algorithm for the same.
4. What is a fractional knapsack problem? Design and analyze greedy algorithms to solve it.
5. Is Selection sorting a greedy algorithm? If so, what are the functions involved?
6. Give and Explain the Prim’s Algorithm to find out Minimum Spanning Tree with illustration.
Also give its time complexity.
7. Give and Explain the Kruskal’s Algorithm to find out Minimum Spanning Tree with
illustration. Also give its time complexity.

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)

3. Using greedy algorithm find an optimal schedule for following jobs


with n=7a. Profits: (P1,P2,P3,P4,P5,P6,P7) = (3,5,18,20,6,1,38) and
b. Deadline (d1,d2,d3,d4,d5,d6,d7) = (1,3,3,4,1,2,1)
4. 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.

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

1. Explain Dijkstra’s shortest path algorithm with an example. If we want to display an


intermediate node then what change should we make in the algorithm?
2. Define: Directed Acyclic Graph, Dense graph, Sparse graph, Preconditioning.
3. Explain Breadth First Traversal Method for Graph with algorithm.
4. Explain in brief Breadth First Search and Depth First Search Traversal techniques of a Graph.
5. Write pseudo code for the basic depth first search algorithm.
6. Differentiate BFS and DFS.
7. Explain with examples how games can be formulated using graphs?
8. Explain: Articulation Point, Graph, Tree.
9. Write down the algorithm to determine articulation points in a given undirected graph.
Give any application where it is applicable.
10. Explain Topological Sort. Also write its algorithm.

Numerical/Derivable

1. Explain with example how games can be formulated using graphs?


2. Write an algorithm to find out the articulation points of an undirected graph. Find out
articulation points for the following graph. Consider vertex A as the starting point.

11 | Page
Question Bank Analysis and Design of Algorithms

Backtracking and Branch and Bound


Theory

1. Explain Branch and Bound Technique in brief.


2. Explain use of Branch & Bound Technique for solving Assignment Problem.
3. Explain Minimax principle with its use.
4. Give the algorithm to solve the Tower of Hanoi Problem. Comment on the complexity of the
algorithm.
5. What is Recursion? Give the implementation of the Tower of Hanoi problem using Recursion.
6. Explain Backtracking Method. What is the N-Queens Problem?
7. Explain the use of Backtracking method for solving Eight Queens Problem giving its algorithm.
8. Explain Backtracking with Knapsack problem.
9. Explain with example how a backtracking algorithm is useful in solving a Hamiltonian cycle
problem.

Numerical/Derivable

1. Give solution to 4- Queens Problem using Backtracking Method.


2. Find all possible solution for the 4*4 chess boards, 4 queen’s problems using backtracking.
3. Find an optimal solution to the knapsack instance n=4, M=8, (P1,P2,P3,P4)=(3,5,6,10) and
(W1,W2,W3,W4)=(2,3,4,5) using backtracking. Also draw the corresponding state space tree.

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

1. Explain P and NP Problems giving examples.


2. Compare NP-Hard with NP-Complete problems.
3. What is polynomially turing reducible problem? Explain with example how problem A can
be polynomially Turing reduced to problem B.
4. Define P, NP, NP complete and NP-Hard problems.
5. Explain polynomial reduction.
6. Explain in Brief: P Problem, NP Problem, Heap Tree, Travelling Salesman Problem, MinMax
Principle.

Numerical/Derivable

14 | Page

You might also like