Daa MCQ - Sample-2020 PDF
Daa MCQ - Sample-2020 PDF
Daa MCQ - Sample-2020 PDF
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)
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
B. O(log n)
C. O(n)
D. O(n logn)
Ans-a
c) Network flow
d) Sorting
View Answer
Answer: b
a) 8
b) 9
c) 4
d) 6
Answer: d
View Answer
Answer: c
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
b. 4600 Correct
c. 6900
d. 12890
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)
Select one:
a. Case 3
b. Case 1
d. Case 2
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
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:
b. Number of input
c. Number of passes.
32. Which of the following sorting algorithms does not have a worst case running time of
O(n2) ?
Select one:
a. Quick sort
c. Insertion sort
d. Bubble sort
Select one:
a. N equal parts
Select one:
a. O(n2)
b. O(n)
c. O(nlogn)
d. O(n3) Correct
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
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
d. Bubble sort
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
Select one:
a. BIG O of N log N
b. Gamma of n log N
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).
Select one:
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.
Select one:
a. Objective function
b. Feasible solution
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
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
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
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
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
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.
a. O(V)
b. O (V log E)
c. O(V+E)
d. O ( V2 )
Ans-(C) O(V+E)
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
a) n-queen problem
Answer: d
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
a) 1
b) 2
c) 3
d) 4
Answer: c
a) Dynamic programming
b) Greedy
d) Recursion
Answer: c
(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
a) Greedy algorithm
b) 2D dynamic programming
c) 1D dynamic programming
Answer: b
a) O(p(n))
c) O(p(n2))
Answer: a
a) tractable problems
b) intractable problems
c) undecidable problems
d) decidable problems
Answer: c
a) knapsack 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
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:
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
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
Answer: b
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
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
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
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
S2. Kruskal’s algorithm can efficiently implemented using the disjoint-set data structure.
Answer: d
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
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
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
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
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
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
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
d) dynamic programming
Answer: c