Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

SECTION – A (15 x 1 = 15 MARKS)

Answer All Questions. Each question carries ONE Mark.

1. Choose the correct answer:


I. The bad symbol shift d1 is computed by the Boyer-Moore algorithm which can be expressed by
the formula of _____________.
(a) d1= max{t1(c) *k,1} (b) d1= max{t1(c )- k, 1}
(b) d1= max{t1(c) + k, 1 } (d) d1= max{t1(c) - k}

II. Which of the following is not an Algorithm design technique.


(a) Brute Force (c) Divide & Conquer
(b) Dynamic Programming (d) Hashing

III. The Decrease-and-Conquer technique is used in ________________.


(a) Bubble Sort (c) Insertion Sort
(b) String Matching (d) Heap

IV. O(g(n)) stands for set of all functions with a _____________.


(a) Larger or same order of growth as g(n) (c) Same order of growth as g(n)
(b) Smaller or same order of growth as g(n) (d) Smaller order of growth as g(n)

V. It is convenient to use a ___________to trace the operation of Depth First Search.


(a) Stack (c) Queue
(b) Array (d) String

VI. In Brute Force String matching, while pattern is not found and the text is not yet
exhausted, realign ________ one position to the right.
(a) Left (c) Right
(b) Pattern (d) String

VII. The recurrence relation of Binary Search in worst-case is


(a) T(n) = 2T(n/2) + (n-1) (c) T(n) = 2T(n/2) + n
(b) T(n) = T(n/2) + 1 (d) T(n) = T(n/2) + n

VIII. The time efficiency of the Krushkal’s algorithm is _________.


(a) O(|E| log |E|) (c) O(|E| log |V|)
(b) O(|E| log |V|) (d) O(|E |log |V2|)

IX. The time efficiency of Floyd’s algorithm is ___________.


(a) O(n) (c) O(n2)
(b) O(n3) (d) O( n4)

X. In a Horspool’s algorithm, when searching a pattern with some text, if there is a mismatch occurs

we need to shift the pattern to ____________.

(a) Left Position (c) Right Position


(b) Stop the Process (d) continue with another occurrence

Page 1 of 9
XI. Dynamic programming is a technique for solving problems with _________________ sub-
problems.
(a) Overloading (c) overriding
(b) Overlapping (d) operator

XII. In Tower of Hanoi puzzle to move 6 disc from peg1 to peg3 by using peg2 the number of

moves required are____________.

(a) 61 (c) 62
(b) 63 (d) 64

XIII. Quick Sort is a perfect example of a successful application of the __________________ technique.
(a) Brute Force (c) Divide & Conquer
(b) Decrease and Conquer (d) Dynamic Programming

XIV. A Spanning tree with n vertices has exactly ______ edges.


(a) n (c) n+1
(b) n-1 (d) n2

XV. Analysis of algorithms means to investigate the algorithm's efficiency with respect to
Resources: like running time and __________.
(a) Speed (b) space
(b) Hardware (d) Input

SECTION – B (5 x 3 = 15 MARKS)

Answer any FIVE Questions. Each Question carries THREE Marks.

2. Explain NP and NP Complete problem.

NP problem: NP: the class of decision problems that can be solved by nondeterministic polynomial (NP)
algorithms

NP Complete problem:
A decision problem D is said to be NP-complete if
1. It belongs to class NP.
2. Every problem in NP is polynomial reducible to D

Page 2 of 9
3. Explain Topological Sorting. Find the topological sorting for the following directed graph.

Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for
every directed edge uv, vertex u comes before v in the ordering. Topological Sorting for a graph
is not possible if the graph is not a DAG.

4. Write down the algorithm for closest pair problem. Also find the running time of the
algorithm.

Ans[ ]
Page 3 of 9
5.Consider the following recursive algorithm. (1 + 2 )

a. What is the basic operation in this Algorithm?


b. Set up and solve the recurrence relation for the number of times basic operation is
executed.
Ans[ ]
Basic operation: Multiplication

M(n) = [ M(n-2) + 1 ] +1
M(n) = [M(n -3) + 1 ] + 2
M(n) = M(n -3) + 3
. ….. ……
… i times ….. ….
……… .. … …..
M(n) = M(n -i) + i ------------------- (I)
M(0) = 0
So i = n in (I)
Page 4 of 9
M(n) = M(n -n) + n
M(n) = M(0) + n
M(n) = 0 + n
M(n) = n  𝜽(𝒏)

6. Find the running time of recurrence relation T(n) = 4T(n/2) + n2 using Master Theorem.

Ans[ ]

a= 4
b= 2
d=2
a bd

4 = 22

(nd logn ) = (n2 logn )

7. Using the Horspool’s Algorithm search the pattern BARBER on the following text
JIM_ SAW_ME_IN_ A_BARBERSHOP.

Ans[ ]

SECTION – C (2 x 5 = 10 MARKS)
Page 5 of 9
Answer any TWO Questions. Each Question carries FIVE Marks.

8. Apply Boyers-Moore algorithm to search for the pattern BAOBAB in the text

BESS_KNEW_ABOUT_BAOBABS.

Ans[ ]

9. Write the Warshall’s algorithm and apply it to find the transitive closure for the given
directed graph. (1 + 4)

Page 6 of 9
Ans[ ]

10. Write the Prims algorithm and also find the minimum spanning tree and cost of the following

Page 7 of 9
graph using Prims’s Algorithm.
(1 + 3 + 1)

Ans[ ]

Cost = ae + eb + ec + cd = 2 + 3 + 4 + 4 =13

Page 8 of 9
Ans[ ]

Page 9 of 9

You might also like