Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Daa MCQ - Sample-2020 PDF

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

DAA-SAMPLE-QUESTION-4TH-SEM (CSE AND CSIT)-2020

1. The method will choose when sub problems share sub problems
(a) Divide and conquer
(b) Greedy method
(c) Dynamic programming
(d) Back tracking
Ans- (c)

2. Steps of Divide and Conquer approach


Select one:
a. Divide, Conquer and Combine
b. Combine, Conquer and Divide
c. Combine, Divide and Conquer
d. Divide, Combine and Conquer.

3. How many number of comparisons are required in insertion sort to sort a file if the file is
already sorted?
A. N2

B. N

C. N-1

D. N/2

Ans-c

4. The worst-case time complexity of Quick Sort is________.


A. O(n2)

B. O(log n)

C. O(n)

D. O(n logn)

Ans-a

5. Dijkstra’s Algorithm is used to solve _____________ problems.


a) All pair shortest path

b) Single source shortest path

c) Network flow
d) Sorting

View Answer

Answer: b

6. Consider the following graph.

If b is the source vertex, what is the minimum cost to reach f vertex?

a) 8

b) 9

c) 4

d) 6

Answer: d

7. A graph is said to have a negative weight cycle when?


a) The graph has 1 negative weighted edge

b) The graph has a cycle

c) The total weight of the graph is negative

d) The graph has 1 or more negative weighted edges

View Answer

Answer: c

8. Which one is not the characteristics of algorithm?


a. Finiteness
b. Effectiveness
c. Input
d. Complexity√
9. Worst case time complexity of linear search is
a. O(1)
b. O(n)√
c. O(log n)
d. O(nn)
10. Time Complexity of Binary search is
a. O(nlog n)
b. O(n)
c. O(log n)
d. O(n2)

11. The complexity of searching an element from a set of n elements using Binary search
algorithm is
Select one:

a. O(n log n)

b. O(log n) Correct

c. O(n2)

d. O(n)

12. The total running time of Huffman on the set of n characters is ______.
(a) O(n) (b) O(n log n) (c) O(n2) (d) O(log n)
Ans- (b) O(n log n)

13. The total running time of matrix chain multiplication of n matrices ______.
(a) ϴ (n4) (b) ϴ (n3) (c) ϴ (n2) (d) ϴ (n)
Ans- (b) ϴ (n )
3

14. Which of the following technique is used to solve a fractional knapsack problem?
(a) Greedy (b) Dynamic programming (c) branch and bound (d) backtracking
Ans- Greedy

15. What is the time complexity for the longest common subsequence of two strings of
length m and n.
(a) O(m+n) O(mn) (b) O(mn) O(m+n) (c) O(mn) O(m+n) (d) O(m+n) O(mn)
Answer: (C)
16. In the development of dynamic programming the value of an optimal solution is
computed in Select one:
a. Top up fashion b. Bottom up fashion Correct c. In any way

17. Which algorithm approach is used in Quick Sort?


a. Divide-and-Conquer√
b. Greedy method
c. Dynamic Programming
d. Branch-and-Bound
18. Creating a heap requires _________ time.
a. O(n)√
b. O(logn)
c. O(nlogn)
d. O(n3)
19. The best case running time for quick sort occurs when pivot element is at _______
position.
a. Leftmost
b. Middle√
c. Rightmost
d. Any
20. The number of operations in Matrix multiplications M1, M2, M3, M4 and M5 of sizes
5X10, 10X100, 100X2, 2X20 and 20X50 Select one:
a. 5830

b. 4600 Correct

c. 6900

d. 12890

21. In which method the decision once made is never changed


(a) Divide and conquer
(b) Greedy method
(c) Dynamic programming
(d) Back tracking
Answer- (b) Greedy method

22. The total running time of Print-LCS()on the set of n characters is ______.
(a) O(m,n)
(b) O(mn)
(c) O(m+n)
(d) O(log mn)
Answer- (c) O(m+n)
23. The total running time of matrix-chain-order() for n matrices ______.
(a) ϴ (n4)
(b) ϴ (n3)
(c) ϴ (n2)
(d) ϴ (n)
Answer- (b) ϴ (n3)

24. Which of the following technique is using for divide and conquer problem?
(a) LCS
(b) Matrix Chain Multiplication
(c) Heap Sort
(d) Activity selection problem
Answer - (c)

25. Which case of Master’s theorem is applicable in the recurrence relation


T(n)=0.5*T(n/2)+1/n?

Select one:

a. Case 3

b. Case 1

c. Master’s theorem is not applicable Correct

d. Case 2

26. If f(n) = O(g(n)) and g(n) = O(h(n)) then

a. f(n) = O(h(n))√
b. f(n) = Theta(h(n))
c. f(n)= Big-omega(h(n))
d. f(n)= small-oh(h(n))
27. In master method if f(n)=O(nlogba-ϵ)then
a. T(n)=Theta(nlogba)√
b. T(n)=Theta(nlogbalg n)
c. T(n)=O(nlogbalg n)
d. T(n)=O(nlogba)
28. If i is the index of a node in a heap, then what are the indices of its left child and right
child? Assume that index of the root starts from 0.
a. 2i+3 and 2i+4
b. 2i+2 and 2i+4
c. 2i+1 and 2i+2√
d. 2i and 2i+2
29. An almost complete binary tree T has 20 nodes. The number of nodes in T having two
children is
a. 7
b. 9√
c. 12
d. 8

30. Division Pattern of Problems in Divide and Conquer approach

Select one:

a. Iterative

b. Recursive Correct

c. Parallel

d. Random

31. The running time of quick sort depends on the selection of.

Select one:

a. Selection of pivot elements Correct

b. Number of input

c. Number of passes.

d. Arrangements of the elements

32. Which of the following sorting algorithms does not have a worst case running time of
O(n2) ?

Select one:

a. Quick sort

b. Merge sort Correct

c. Insertion sort
d. Bubble sort

33. Merge Sort divides the list in

Select one:

a. N equal parts

b. Two equal parts Correct

c. Two parts, may not be equal

d. N parts, may not be equal.

34. Time complexity of matrix chain multiplication

Select one:

a. O(n2)

b. O(n)

c. O(nlogn)

d. O(n3) Correct

35. For the function f(n)=2n2+5, which is not correct bound?


a. O(n2)
b. O(n3)
c. O(n)√
d. O(n4)
36. What is the value of the following recurrence: T(n)=5T(n/5)+sqrt(n)?
a. Theta(n)√
b. Theta(sqrt(n))
c. Theta(n2)
d. Theta(nlogn)
37. Suppose T(n)=2T(n/2)+n, T(0)=T(1)=1. Which one of the following is false?
a. T(n)=BigOmega(nlgn)
b. T(n)=Theta(nlgn)
c. T(n)=BigOmega(n2)√
d. T(n)=O(nlgn)
38. For the function f(n)=2n3+n, which is not correct bound?
a. Ω(n2)
b. Ω (n!) √
c. Ω (n)
d. Ω (1)
39. The correct order of growth in increasing order for the following functions is:
nlogn,n,logn,n2,2n
a. nlogn, n2, n, logn, 2n
b. n, nlogn, n2, logn, 2n
c. logn, n, nlogn, n2, 2n √
d. n, logn, n2, nlogn, 2n
40. log(n!)=O(?).
a. O(nlogn)√
b. O(n)
c. O(n3)
d. O(logn)
41. F(n) = little omega g(n), when
a. limn->∞ f(n)/g(n) =∞√
b. limn->∞ f(n)/g(n) =0
c. limn->0 f(n)/g(n) =∞
d. limn->0 f(n)/g(n) =0

42. What is the time complexity for activity selection problem to select optimal job from
the schedule?
(a) ϴ(n)
(b) ϴ (lg n)
(c) ϴ (log n2)
(d) O (nlog n)
Answer: (a)ϴ(n)

43. Which is optimal value in the case of fractional knapsack problem, capacity of knapsack
is 20
item : 1 2 3
profit : 25 24 15
weight : 18 15 10

(a) 498
(b) 480
(c) 499
(d) 485

Ans- (a)

44. What is an optimal Huffman code for alphabet ‘a’ of the following set of frequencies
a: 05, b: 48, c: 07, d: 17, e: 10, f: 13
(a) 1010 (b)0101 (c) 1001 (d) 1100
Ans- (a) 1010

45. We use dynamic programming approach when

(A) It provides optimal solution


(B) The solution has optimal substructure
(C) The given problem can be reduced to the 3-SAT problem
(D) It’s faster than Greedy

Answer: (B)
46. Which notation is used for average case analysis?
a. Big-oh
b. Big-omega
c. theta√
d. small-oh
47. Which method is also called Guess method?
a. Master method
b. Recursion-tree
c. Substitution√
d. dynamic programming
48. Which tree is used to make a guess for solving recurrence relation?
a. Binary search tree
b. Recursion tree√
c. Heap tree
d. Binary tree
49. If an optimal solution can be created for a problem by constructing optimal solutions for
its subproblems, the problem possesses ____________ property.
a. Overlapping subproblems
b. Optimal substructure√
c. Memoization
d. Greedy

50. Find the maximum profit using 0/1 knapsack problem where the capacity of knapsack is
30.
item: 1 2 3
profit: 25 24 15
weight: 18 15 10

(a) 39
(b) 49
(c) 40
(d) 54

Answer- (a) 39
51. A sort which relatively passes through a list to exchange the first element with any
element less than it and then repeats with a new first element is called________.

Select one:

a. Quick sort

b. heap sort

c. Insertion sort Correct

d. Bubble sort

52. Apply Master theorem to T(n)=3.T(n/2)+n^2 and write what is f(n)

Select one:

a. f(n)=n/2+n^2

b. f(n)=n/2

c. f(n)=n^2 Correct

d. f(n)=3n/2

53. Run Time of Merge Sort is

Select one:

a. BIG O of N log N

b. Gamma of n log N

c. Theta of N log N Correct

d. Omega of N log N.

54. Time complexities of three algorithms are given. Which should execute the slowest for
large values of N?

Select one:

a. O(N) Correct

b. O(N ½)
c. O(log n).

55. In dynamic programming, the output to stage n become the input to

Select one:

a. stage n-1 Correct

b. stage n+1

c. stage n itself

d. stage n-2

56. Time complexity of knapsack 0/1 where n is the number of items and W is the capacity
of knapsack.

Select one:

a. O(W)

b. O(n)

c. O(nW) Correct.

57. In dynamic programming, the output to stage n become the input to

Select one:

a. Objective function

b. Feasible solution

c. Decision stages Correct

d. Optimum solution

58. Master theorem applies to recurrences of the form (a=1 and b>1) are two constants.

Select one:

a. T(n)=a.T(n/b)+f(n) Correct

b. T(n)=n.T(n/2)+b.f(n)

c. T(n)=a.T(n-1)+b
d. T(n)=n.T(n-3)+b Incorrect

59. Time complexity of LCS

Select one:

a. O(m!)

b. O(mn) Correct

c. O(n!)

60. What is an optimal Huffman code in variable length for alphabet ‘e’ of the following set
of frequencies?
a: 45, b: 13, c: 12, d: 16, e: 9, f: 5
(a) 0
(b)1011
(c) 111
(d) 1101
Answer - (d) 1101

61. LCS for input sequences “AGGTAB” and “GXTXAYB” is


(a) AGGTAB
(b) GTAB
(c) GGAT
(d) AGGTB
Answer: (B) GTAB

62. If a problem can be broken into subproblems which are reused several times, the problem
possesses ____________ property.
a. Overlapping subproblems√
b. Optimal substructure
c. Memoization
d. Greedy
63. Which of the following is/are property/properties of a dynamic programming problem?
a. Optimal substructure
b. Overlapping subproblems
c. Greedy approach
d. Both optimal substructure and overlapping subproblems√
64. Which of the following problems should be solved using dynamic programming?
a. Mergesort
b. Binary search
c. Longest common subsequence√
d. Quicksort
65. In dynamic programming, the technique of storing the previously calculated values is
called ___________
a. Saving value property
b. Storing value property
c. Memoization√
d. Mapping

66. Which is the optimal value in case of activity selection problem?


Job :1 2 3 4 5 6 7
St :1 3 0 5 3 5 6
Ft :4 5 6 7 9 9 10
(a) 1, 3, 4, 6, 7
(b) 2, 4, 7
(c) 1, 4
(d) 1
Answer:- (c)

67. Find an minimum number of scalar multiplications required for a matrix chain product
whose sequence of dimension s is <5,4,6,2,7> .
(a) 156 (b) 154 (c) 158 (d) 157
Ans- (c) 158

68. Which is the optimal value in case of activity selection problem?


Job :1 2 3 4 5 6 7
St :1 3 4 5 6 8 10
Ft :4 5 6 7 9 9 14
(a) 1, 3, 4, 6, 7
(b) 2, 4, 7
(c) 1, 3,5,7
(d) 1,2,5,6,7
Answer: - (c)1,3,5,7

69. Find the minimum number of scalar multiplications required for a matrix chain product
whose sequence of dimension s is <10,20,30,40,50> .
(a) 25000
(b) 30000
(c) 45000
(d) 51000
Answer - (b) 30000

70. The running time of matrix chain multiplication problem is


a. O(n2)
b. O(n3)√
c. O(n)
d. O(1)
71. How many bases are there in a DNA strand?
a. 2
b. 5
c. 3
d. 4√
72. If Z = <B, C, D, B> is a subsequence of X = <A, B, C, B, D, A, B>, then the
corresponding index sequence is
a. <3, 4, 6, 7>
b. <2, 3, 5, 7>√
c. <1, 2, 4, 6>
d. <2, 4, 5, 6>

73. A minimum cost spanning tree for a graph with e edges and v vertices can be found in
(a)O(eloge) time in general and in O(e) time if e is sufficiently large
compared with the number of vertices.
(b) O(vlogv) time in general and in O(v) time if v is sufficiently large
compared with the number of edges .
(c) O(vloge) time in general and in O(e) time if e is sufficiently large
compared with the number of vertices.
(d) O(elogv) time in general and in O(v) time if v is sufficiently large
compared with the number of edges.

74. Which of the following is the single-source shortest path problems?


(a)Prim’s algorithm
(b)Kruskal’s algorithm
(c)MST
(d)Bellman-Ford algorithm
75. Which of the following is the all-pairs shortest path problem?
(a)Floyd-Warshall algorithm
(b)Bellman-Ford algorithm
(c)Dijkstra’s algorithm
(d)Kruskal’s algorithm
76. The best case time complexity of Rabin-Karp algorithm is
(a)Θ(m)
(b) Θ(n)
(c) Θ(m-n)
(d)Θ(m-n+1)
77. The complexity class NP is the class of languages that can be
(a)solvable in polynomial time.
(b)verified in polynomial time.
(c)solvable and verifiable in polynomial time.
(d)deterministic.

78. Which of the following is true?


(a)P ⊆NP
(b)P≠Co-NP
(c)NP≠Co-NP
(d)P=NP
79. Which of the following is NP complete problem?
(a)Kruskal’s algorithm
(b)Clique problem
(c)Prim’s algorithm
(d)Bellman-Ford algorithm

80. Which of the following standard algorithms is not a Greedy algorithm?


a. Bellman-Ford shortest path algorithm√
b. Kruskal’s minimum spanning tree
c. Dijkstra shortest path algorithm
d. Huffman coding
81. Which of the following methods can be used to solve the fractional Knapsack problem?
a. Dynamic programming
b. Greedy method√
c. Divide-and-Conquer
d. Backtracking
82. You are given a knapsack that can carry a maximum weight of 60. There are 4 items with
weights {20, 30, 40, 70} and values {70, 80, 90, 200}. What is the maximum value of the
items you can carry using the knapsack if fractions are allowed?
a. 160√
b. 200
c. 170
d. 90
83. How many edges are there in a minimum cost spanning tree if there are n number of
vertices in the corresponding graph?
a. n/2-1
b. n-2
c. n/2
d. n-1√
84. The output of Prim’s and Kruskal’s algorithm is
a. Maximum spanning tree
b. Spanning tree
c. Minimum spanning tree√
d. None of these
85. What is the time complexity of Huffman coding algorithm?
a. O(n)
b. O(nlogn)√
c. O(n2)
d. O(nlog2n)
86. Activities ai and aj are compatible if
a. si ≥ fj or sj ≥ fi√
b. si ≤ fj or sj ≥ fi
c. si ≥ fj or sj ≤ fi
d. si ≤ fj or sj ≤ fi

87. The running time of kruskal’s algorithm for MST ---------------.


(a) O(E) (b) O(V) (c) O(E log V) (d) O(V2)
Ans-(c) O(E log V)

88. The running time of BFS is ------------.

a. O(V)
b. O (V log E)
c. O(V+E)
d. O ( V2 )

Ans-(C) O(V+E)

89. The running time of Floyd-Warshall algorithm is --------------------.


(A) ϴ (n) (B) ϴ (n3) (C) ϴ (n2) (D) ϴ (n log n)
Ans-(b) ϴ (n )
3

90. How many passes is required to find out shortest path using Bellman Ford algorithm?
(a) |V| (b) |E| (c) |V-1| (d) |E-1|
Ans-(c)

91. Dijkstra algorithm is also called the ...................... shortest path problem.
A) multiple source
B) single source
C) single destination
D) multiple destination
Ans-(B)
92. 0/1 Knapsack problem is the problem in which
(a)item must either be taken or left behind.
(b)item can be taken fractionally or more than once.
(c)item is only removed from knapsack.
(d)item is only inserted into the knapsack.
93. Travelling salesman problem is
(a)P
(b)NP
(c)NPC
(d)Co-NP
94. A language is NP complete if
(a)L is in NP
(b)L is NP-hard
(c)L is in P
(d)L is in NP and L is NP-hard
95. If L is a language such that complement of L is polynomial time reducible to L for some
complement language belongs to NPC then L is
(a)NPC
(b)NP hard
(c)P
(d)Co-NP
96. If S={1,2,5,7,14,15,18,20} and t=14,then the subset
(a)S1= {14} or S1={1,2,5} is a subset sum problem.
(b)S1={14} or S1={2,5,7} is a subset sum problem.
(c)S1={14} or S1={7, 14} is the subset sum problem.
(d)S1=empty set is the subset sum problem.
97. Merge sort uses
(a)Greedy method
(b)Array
(c)Linked list
(d)Divide-Conquer strategy

98. Which of the problems cannot be solved by backtracking method?

a) n-queen problem

b) subset sum problem

c) hamiltonian circuit problem

d) travelling salesman problem

Answer: d

99. Backtracking algorithm is implemented by constructing a tree of choices called as?

a) State-space tree

b) State-chart tree

c) Node tree
d) Backtracking tree

Answer: a

100. How many solutions are there for 8 queens on 8*8 board?

a) 12

b) 91

c) 92

d) 93

Answer: c

101. In how many directions do queens attack each other?

a) 1

b) 2

c) 3

d) 4

Answer: c

102. If a problem can be solved by combining optimal solutions to non-overlapping


problems, the strategy is called _____________

a) Dynamic programming

b) Greedy

c) Divide and conquer

d) Recursion

Answer: c

103. In the deletion operation of max heap, the root is replaced by

(a)next available value in the left sub-tree


(b)next available value in right sub-tree
(c)first element of the last level
(d)last element of the last level
104. Which of the following sorting procedures is the slowest?

(a) Quick sort


(b) Heap sort
(c) Shell sort
(d) Bubble sort
105. Two main measures for the efficiency of an algorithm are

(a) Processor and memory


(b) Complexity and capacity
(c) Time and space
(d) Data and space
106. The concept of order Big O is important because

(a)It can be used to decide the best algorithm that solves a given problem
(b) It determines the maximum size of a problem that can be solved in a given amount of time
(c) It is the lower bound of the growth rate of algorithm
(d) It determines the minimum size of a problem that can be solved in a given amount of time

107. In activity selection problem, activities are sorted according to


a. monotonically decreasing order of finish time
b. monotonically increasing order of start time
c. monotonically increasing order of finish time√
d. monotonically decreasing order of start time
108. In greedy approach, which of the following problem fits ordering paradigm?
a. KNAPSACK PROBLEM
b. JOB SEQUENCING WITH DEADLINES
c. SINGLE-SOURCE SHORTEST PATHS √
d. MINIMUM-COST SPANNING TREE
109. In greedy approach, which of the following problem fits subset paradigm?
a. OPTIMAL STORAGE ON TAPE
b. TREE VERTEX SPLITTING √
c. OPTIMAL MERGE PATTERNS
d. SINGLE-SOURCE SHORTEST PATHS
110. Which of the following properties is exhibited by both dynamic programming and
greedy method?
a. Greedy choice property
b. Overlapping subproblems
c. Optimal substructure√
d. None of these
111. Longest common subsequence is an example of ____________

a) Greedy algorithm

b) 2D dynamic programming

c) 1D dynamic programming

d) Divide and conquer

Answer: b

112. The worst-case efficiency of solving a problem in polynomial time is?

a) O(p(n))

b) O(p( n log n))

c) O(p(n2))

d) O(p(m log n))

Answer: a

113. Problems that cannot be solved by any algorithm are called?

a) tractable problems

b) intractable problems

c) undecidable problems

d) decidable problems

Answer: c

114. Which of the following problems is similar to that of a Hamiltonian path


problem?

a) knapsack problem

b) closest pair problem

c) travelling salesman problem

d) assignment problem

Answer: c
115. Which type of the following algorithm proceeds in top-down manner?
a. Dynamic Programming
b. Divide-and-Conquer
c. Branch-and-Bound
d. Greedy method√
116. The 0/1 knapsack problem can be solved by which technique?
a. Greedy method
b. Dynamic Programming√
c. Divide-and-Conquer
d. None of these
117. The objects in fractional knapsack problem are arranged in _______ to get
maximum profit.
a. Increasing order of weights
b. Decreasing order of profits
c. Decreasing order of profit per weight√
d. Increasing order of profit per weight
118. Path Compression algorithm performs in which of the following operations?
a. Create operation
b. Insert operation
c. Find operation√
d. Delete operation
119. In a disjoint set forest, each member points only to its
a. Children
b. Left child
c. Right child
d. Parent √
120. In the Union/Find algorithm, the ranks of the nodes on a path will increase
monotonically from?
a. leaf to root√
b. root to node
c. root to leaf
d. left subtree to right subtree

121. The running time of Prim’s algorithm for MST ---------------.


(a) O(E) (b) O(V) (c) O(E log V) (d) O(V log E)
Ans-(c) O(E log V)

122. The running time of DFS is ------------.


(A) O (1) (B) O(V) (C) O(V+E) (D) O(E)
Ans-(C) O(V+E)
123. The running time of BELLMAN-FORD algorithm is --------------------.
(A) O (V) (B) O (E) (C) O (VE) (D) O (V+E)
Ans-(c) O(VE)

124. Floyd Warshall’salgorithm is used for_______________ shortest path problem.


A) multiple source
B) single source
C) All pair
D) singlepair
Answer : (c) All Pair

125. Which operation is not supported by disjoint set?


(A) FIND-SET(x)
(B) DELETE-SET(x)
(C) UNION(x)
(D) MAKE-SET(x)

Answer: (B) DELETE-SET(x)


126. If we have a chain of three matrices as:<A1,A2,A3> with the corresponding
dimensions 10x100,100x5 and 5x50 respectively then which of the following
gives less number of scalar multiplications
a)A1(A2A3)
b) (A1A2)A3
c) A1(A3A2)
d) (A1A3)A2
127. Complexity of matrix chain order is
3
a) O(n )
b) o(n3)
c) w(n2)
d) Ω(n3)
128. Activities i and j are compatible if
a)sj≥ fi
b) sj≤ fi
c)fj≥si
d) si=sj
129. The 5 items I=<I1,I2,I3,I4,I5> along with their respective weights and values are
w=<5,10,20,30,40> and v=<30,20,100,90,160> . The solution to the fractional knapsack
problem whose capacity W=60 is
a)140
b) 270
c)160
d) 130
130. If we have a sequence of characters with their frequencies a:4,b:2,c:3,d:1.Then
the codes of each character using Huffman coding technique are:
a) a=00,b=1011,c=11,d=100
b) a=000,b=100,c=111,d=100
c) a=0,b=101,c=11,d=100
d) a=1,b=010,c=00,d=011
131. One application of disjoint set data structures are to determining
a)the connected components of an undirected graph
b)the stack representation
c)disjoint set forests
d)rank

132. A MAKE-SET operation creates a tree with _________ node.


a. 2
b. 3
c. 1√
d. 4
133. Running time of Prim’s algorithm in adjacency matrix implementation is
a. O(ElogV)
b. O(V2)√
c. O(VlogE)
d. O(VlogV)
134. Which of the following is false in the case of a spanning tree of a graph G?
a. It is a tree that spans G
b. It is a subgraph of G
c. It includes every vertex of G
d. It can be cyclic or acyclic√
135. The travelling salesman problem can be solved using _________.
a. A spanning tree
b. A minimum spanning tree√
c. Bellman – Ford algorithm
d. DFS traversal
136. Consider a undirected graph G with vertices { A, B, C, D, E}. In graph G, every
edge has distinct weight. Edge CD is edge with minimum weight and edge AB is edge
with maximum weight. Then, which of the following is false?
a. Every minimum spanning tree of G must contain CD
b. If AB is in a minimum spanning tree, then its removal must disconnect G
c. No minimum spanning tree contains AB√
d. G has a unique minimum spanning tree
137. What are the appropriate data structures for following algorithms?
i. Breadth First Search
ii. Depth First Search
iii. Prim's Minimum Spanning Tree
iv. Kruskal' Minimum
SpanningTree

(A) Stack, Queue, Priority queue, Union Find


(B) Queue, Stack, Priority queue, Union Find
(C) Stack, Queue, Union Find, Priority queue
(D) Priority Queue, Queue, Stack, Union Find

Answer: (B)

138. How many different spanning tree we can have of a complete graph with n-
vertices.
(A) n
(B) n-1
(C) nn
(D) nn-2
Answer: (D)

139.
Which one of the following Adjacency List representation (implemented using linked list) is
correct for the above graph?

(a)

(b)
(c)

(d)

Ans (a)

140. Indicate the runtime of Dijkstra's algorithm when the implementation is based on
a binary heap. (E = edges; V = vertices)
a. O(ElogV)√
b. O(V2)
c. O(E + VlogV)
d. O(E + V)
141. Which of the following is the most commonly used data structure for
implementing Dijkstra's Algorithm?
a. Max priority queue
b. Stack
c. Circular queue
d. Min priority queue√
142. Dijkstra’s Algorithm cannot be applied on ______________
a. Directed and weighted graphs
b. Graphs having negative weight function√
c. Unweighted graphs
d. Undirected and unweighted graphs
143. The Bellmann Ford algorithm returns _______ value.
a. Boolean√
b. Integer
c. String
d. Double
144. Bellmann ford algorithm provides solution for ____________ problems.
a. All pair shortest path
b. Sorting
c. Network flow
d. Single source shortest path√
145. How many solution/solutions are available for a graph having negative weight
cycle?
a. One solution
b. Two solutions
c. No solution√
d. Infinite solutions
146. Consider the following graph:

What is the minimum cost to travel from node A to node C?


a. 5
b. 2√
c. 1
d. 3

147. In which sequence the following Graph will be traversed using DFS (starting from
vertex no 2).

(A) 2013
(B) 2301
(C) 2130
(D) 2031

Answer: (a) 2 0 1 3

148. Floyd Warshall’s Algorithm is used for solving ____________


a. All pair shortest path problems√
b. Single Source shortest path problems
c. Network flow problems
d. Sorting problems
149. What approach is being followed in Floyd Warshall Algorithm?
a. Greedy technique
b. Dynamic Programming√
c. Linear Programming
d. Backtracking
150. Floyd Warshall’s Algorithm can be applied on __________
a. Undirected and unweighted graphs
b. Undirected graphs
c. Directed graphs√
d. Acyclic graphs
151. Which tree is used to solve problems using backtracking and branch-and-bound
method?
a. Binary search tree
b. State space tree√
c. Heap tree
d. AVL tree
152. Tree organizations that are problem instance dependent are called
_____________ trees.
a. Static tree
b. Expression tree
c. Dynamic tree√
d. Threaded binary tree
153. States that correspond to solutions to the problem are called ____________.
a. Problem state
b. Answer state
c. Solution state
d. Goal state√
154. Which search method is used in Backtracking?
a. Breadth-first search
b. Depth-first search√
c. Least cost search
d. Max profit search
155. A node is called ___________ if it cannot lead to a feasible (or optimal) solution.
a. Nonpromising√
b. Promising
c. Succeeding
d. Preceding
156. A node which has been generated and all of whose children have not yet been
generated is called __________.
a. Expanded node
b. Dead node
c. Feasible node
d. Live node√

157. Which of the following notation gives asymptotic upper bound?


a) Big oh notation
b) Little oh notation
c) Big omega notation
d) Little omega notation

158. Worst case is the worst case time complexity of Prim’s algorithm if adjacency
matrix is used?

a) O(log V)

b) O(V2)

c) O(E2)

d) O(V log E)

Answer: b

159. Fractional knapsack problem is also known as __________

a) 0/1 knapsack problem

b) Continuous knapsack problem

c) Divisible knapsack problem

d) Non continuous knapsack problem

Answer: b

160. Given items as {value,weight} pairs {{40,20},{30,10},{20,5}}. The capacity of


knapsack=20. Find the maximum value output assuming items to be divisible.

a) 60

b) 80

c) 100

d) 40

Answer: a
161. Which of the following algorithms is the best approach for solving Huffman
codes?

a) exhaustive search

b) greedy algorithm

c) brute force algorithm

d) divide and conquer algorithm

Answer: b

162. The type of encoding where no character code is the prefix of another character
code is called?

a) optimal encoding

b) prefix encoding

c) frequency encoding

d) trie encoding

Answer: b

163. The result of intersection of o(g(n)) and w(g(n)) is the


a) Singleton set
b) Empty set
c) Lower bound set
d) Upperbound set
164. Which of the following is correct?
a) n!=w(nn)
b)n!=O(2n)
c) n!=w(n2)
d) n!=o(nn)

165. How many methods are there for solving recurrences?


a) 2
b) 3
c) 4
d) 5

166. The solution of the recurrence T(n)=T(n0.5)+1 is


a) O(loglogn)
b) O(logn)
c) Ω(logn)
d) ʘ(loglogn)

167. The lower bound for decision tree sorting is


a) Ω(nlgn)
b) O(nlgn)
c) o(nlgn)
d) w(nlgn)
168. Which of the following is the LCS of the sequences X={A,B,C,B,D,A,B}
andY={B,D,C,A,B,A}?
a){B,D,A,C}
b) {B,D,A,B}
c){B,C,D,B}
d){B,C,A,B}

169. Which one is the correct MST for the following graph –

(a)

(b)

(c)
(d)
Answer: (a)

170. Consider the following graph. Which one from the four options depicts the
shortest path (represented using solid lines) generated by applying Dijkstra’s algorithm to
it?

4
A B
3
(a)
1 24
E
(b)A B
3
(c) 4 3
1 A C 24 BD
2 E
3
(d)A B
1 24 3
3 E
1 A
Answer C (a) 2 2 BD
3 E
3
1 C 2 D
2 3 E
C
171. 2Which ofDthe following is false?
a) The spanning trees 3do not have any cycles
C D
b) MST2have n – 1 edges if the graph has n edges
c) Edge e belonging to a cut of the graph if has the weight smaller than any other edge in
the same cut, then the edge e is present in all the MSTs of the graph
d) Removing one edge from the spanning tree will not make the graph disconnected

Answer: d

172. Kruskal’s algorithm is a ______

a) divide and conquer algorithm

b) dynamic programming algorithm

c) greedy algorithm

d) approximation algorithm

Answer: c
173. What is the time complexity of Kruskal’s algorithm?

a) O(log V)

b) O(E log V)

c) O(E2)

d) O(V log E)

Answer: b

174. Consider the following statements.

S1. Kruskal’s algorithm might produce a non-minimal spanning tree.

S2. Kruskal’s algorithm can efficiently implemented using the disjoint-set data structure.

a) S1 is true but S2 is false

b) Both S1 and S2 are false

c) Both S1 and S2 are true

d) S2 is true but S1 is false

Answer: d

175. Consider the given graph.

What is the weight of the minimum spanning tree using the Prim’s algorithm,starting from vertex
a?

a) 23

b) 28
c) 27

d) 11

Answer: c

176. In the 8-Queen problem, the solution space consists of _________ number of
tuples if only explicit constraint is applied.
a. 88√
b. 8!
c. 82
d. 28
177. The solution to 8-queen problem is
a. (1, 5, 4, 2, 3, 6, 8, 7)
b. (8, 6, 3, 4, 5, 1, 2, 5)
c. (7, 5, 8, 6, 4, 1, 3, 2)
d. (4, 6, 8, 2, 7, 1, 3, 5)√
178. The branch-and-bound method was first proposed by A. H. Land and A. G. Doig
in ___________.
a. 1950
b. 1970
c. 1960√
d. 1940
179. Which technique is not used in branch-and-bound strategy?
a. Max Profit search√
b. Least Cost search
c. First-in-first-out search
d. Last-in-first-out search
180. The number of nodes generated in the state space tree for 4-queens’ problem is
a. 66
b. 46
c. 65√
d. 58
181. In fixed-tuple formulation of 0/1 knapsack problem consisting of 4 objects, the
number of nodes generated in the tree organization is
a. 32
b. 31√
c. 33
d. 30

182. Consider the following graph.

Which one of the following cannot be the sequence of edges added, in that order, to a minimum
spanning tree using Kruskal’s algorithm?
(A) (a—b),(d—f),(b—f),(d—c),(d—e)
(B) (a—b),(d—f),(d—c),(b—f),(d—e)
(C) (d—f),(a—b),(d—c),(b—f),(d—e)
(D) (d—f),(a—b),(b—f),(d—e),(d—c)
Answer: (D)

183. The Breadth First Search algorithm has been implemented using the queue data
structure. One possible order of visiting the nodes of the following graph is

(A) MNOPQR
(B) NQMPOR
(C) QMNPRO
(D) QMNPOR

Answer: (C)
184. What is the basic formula applied in Rabin Karp Algorithm to get the
computation time as Theta(m)?
a) Halving rule

b) Horner’s rule

c) Summation lemma
d) Cancellation lemma

Answer: b

185. What is the basic principle in Rabin Karp algorithm?


a) Hashing
b) Sorting
c) Augmenting
d) Dynamic Programming
Answer: a

186. Which of the following is false in the case of a spanning tree of a graph G?
a) It is tree that spans G

b) It is a subgraph of the G

c) It includes every vertex of the G

d) It can be either cyclic or acyclic

Answer: d

187. Consider a complete graph G with 4 vertices. The graph G has ____ spanning
trees.
a) 15

b) 8

c) 16

d) 13

Answer: c

188. The travelling salesman problem can be solved using _________


a) A spanning tree

b) A minimum spanning tree

c) Bellman – Ford algorithm

d) DFS traversal

View Answer

Answer: b
189. Consider the following graph. Which one is the correct spanning tree using Prim’s
algorithm?

(a)

(b)

(c)
(d)

Answer : (a)
190. Which one of the correct matrix for above graph in Floyd Warshal’s algorithm?

(a)

(b)

(c)

(d)

Answer (a)
191. The number of operations supported to specify nondeterministic algorithms is
a. 5
b. 4
c. 3√
d. 2
192. The class of problems that can be solved by nondeterministic polynomial time
algorithm is known as ________________.
a. NP Complete
b. P
c. NP√
d. NP Hard
193. The time complexity of traveling salesperson problem is _________.
a. O(2n/2)
b. O(n22n)√
c. O(2n)
d. O(n2)
194. The number conditions to be satisfied by a problem to be NP-Complete is
__________.
a. 1
b. 3
c. 4
d. 2√
195. Which class the Hamiltonian cycle problem belongs to?
a. Class P
b. Class NP
c. Class NP Hard
d. Class NP Complete√
196. Which of the following relationships between different complexity classes is not
true?
a. P is a subset of NP
b. NP Complete is a subset of NP
c. NP Complete is a subset of NP Hard
d. NP Hard is a subset of NP√
197. Which of the following statements is not true?
a. Class P is closed under concatenation
b. Class P is closed under complementation
c. Class P is closed under union
d. Class P is not closed under intersection√
198. The problems that can be solved in polynomial time are __________ problems.
a. Tractable√
b. Intractable
c. Decidable
d. Undecidable

199. Floyd Warshall Algorithm can be used for finding _____________


a) Single source shortest path
b) Topological sort

c) Minimum spanning tree

d) Transitive closure

View Answer

Answer: d

200. Minimum number of unique colors required for vertex coloring of a graph is
called?
a) vertex matching

b) chromatic index

c) chromatic number

d) color number

View Answer

Answer: c

201. Which of the following is an NP complete problem?


a) Hamiltonian cycle

b) Travelling salesman problem

c) Calculating chromatic number of graph

d) Finding maximum element in an array

View Answer

Answer: c

202. What is the recurrence relation for the linear search recursive algorithm?
a) T(n-2)+c

b) 2T(n-1)+c

c) T(n-1)+c
d) T(n+1)+c

Answer: c

203. Merge sort uses which of the following technique to implement sorting?
a) backtracking

b) greedy algorithm

c) divide and conquer

d) dynamic programming

Answer: c

You might also like