DAA MCQs Answer
DAA MCQs Answer
DAA MCQs Answer
Module-I
1. Following is true for understanding of a problem D
A. Knowing the knowledgebase
B. Understanding the subject on which the problem is based
C. Communication with the client
D. All of the above
2. . ______is the first step in solving the problem B
A. Understanding the Problem
B. Identify the Problem
C. Evaluate the Solution
D. None of these
3. ______is the last step in solving the problem C
A. Understanding the Problem
B. Identify the Problem
C. Evaluate the Solution
D. None of these
4. The complexity of linear search algorithm is A
a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)
6. While solving the problem with computer the most difficult step is __________. C
A. describing the problem
B. finding out the cost of the software
C. writing the computer instructions
D. testing the solution
7. The correctness and appropriateness of ___________ can be checked very easily. A
A. algorithmic solution
B. heuristic solution
C. random solution
D. none of these
17. In quick sort, the number of partitions into which the file of size n is divided by a C
selected record is
A. n
B. n – 1
C. 2
D. n/2
18. The running time of the following sorting algorithm depends on whether the B
partitioning balanced or unbalanced.
A. Insertion sort
B. Quick sort
C. Selection sort
D. Merge sort
19. The worst-case time complexity of Quick Sort is________. A
A. O(n2)
B. O(log n)
C. O(n)
D. O(n logn)
20. The worst-case time complexity of Merge Sort is________. B
A. O(n2)
B. O(log n)
C. O(n)
D. O(n logn)
21. The algorithm like Quick sort does not require extra memory for carrying out the A
sorting procedure. This technique is called __________.
A. in-place
B. stable
C. unstable
D. in-partition
24. The time factor when determining the efficiency of algorithm is measured by B
A. Counting microseconds
B. Counting the number of key operations
C. Counting the number of statements
D. Counting the kilobytes of algorithm
25. A list of n strings, each of length n, is sorted into lexicographic order using the A
merge-sort algorithm. The worst case running time of this computation is
A. O (n log n)
B. O (n2 log n)
C. O (n2 + log n)
D. O (n2)
26. Which of the following case does not exist in complexity theory? D
A. Best case
B. Worst case
C. Average case
D. Null case
27. The concept of order Big O is important because A
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. Both A and B
28. When determining the efficiency of algorithm, the space factor is measured by A
a. Counting the maximum memory needed by the algorithm
b. Counting the minimum memory needed by the algorithm
c. Counting the average memory needed by the algorithm
d. Counting the maximum disk space needed by the algorithm
39. For merging two sorted lists of sizes m and n into a sorted list of size m n, requires C
________ number of comparisons.
A. O(m)
B. O(n)
C. O(m+n)
D. O(log m + log n)
40. The running time of the following sorting algorithm depends on whether the B
partitioning balanced or unbalanced.
A. Insertion sort
B. Quick sort
C. Selection sort
D. Merge sort
41. Which of the following is not a stable sorting algorithm in its typical C
implementation.
A Insertion Sort
B Merge Sort
C Quick Sort
D Bubble Sort
42. Which of the following method is taking overcharge for some operations in B
amortized analysis?
(A A. Aggregate method B. accounting method C. potential method
D. both (A) and (C)
43. Which of the following method is most flexible in amortized analysis? C
A. Aggregate method
B. accounting method
C. potential method
D. both (A) and (B)
44. Which of the following method is taken different operations different charges in B
amortized analysis?
A. Aggregate method
B. accounting method
C. potential method
D both (A) and (B)
45. Which of the following method is computing total cost of an algorithm in A
amortized analysis?
A. Aggregate method
B.accounting method
C. potential method
D. both (C) and (B)
46. Which of the following method is credit as the potential energy to pay for future C
operations?
A. Aggregate method
B. accounting method
C. potential method
D. both (A) and (B)
47. The time complexity of the normal quick sort, randomized quick sort algorithms B
in the worst case is
A. O(n2), O(n log n)
B. O(n2), O(n2)
C. O(n log n), O(n2)
D. O(n log n), O(n log n)
48. The Sorting method which is used for external sort is C
A. Bubble sort
B. Quick sort
C. Merge sort
D. Radix sort
49. In analysis of algorithm, approximate relationship between the size of the job and D
the amount of work required to do is expressed by using _________
A. Central tendency
B. Differential equation
C. Order of execution
D. Order of magnitude
50. If A is a matrix of order m x n and B is a matrix of order n x p then order of AB is D
A. pxm
B. pxn
C. nxp
D.m x p
Module-II
1. The disjoint set is an abstract data type that supports the operations, C
A. Union
B. Find
C. both A and B
D. none
2. A graph G is said to be ____________ if and only if it contains no articulation B
points.
A. Connected
B. Biconnected
C. either A or B
D. both A and B
3. If two sets A and B have no common elements i.e (A intersection B) has no C
element then such
sets are known as ?
a. Intersection
b. Union
c. Disjoint
d. Complemen
14. What is the asymptotic runtime for traversing all nodes in a binary search tree B
with n nodes and printing them in order?
A. O(n ⋅ log(n))
B. O(n)
C. O( n)
D. O(log(n))
E. O(n^2 )
15. A minimal spanning tree of a graph G is.... ? D
a. A spanning sub graph
b. A tree
c. Minimum weights
d. All of above
16. The total running time of optimal binary search tree of n nodes C
(A) O(n2)
(B) O(n)
(C) O(n3)
(D) O(n log n)
17. A binary tree that has n leaf nodes. The number of nodes of degree 2 in this tree B
is ?
a. log2n
b. n - 1
c. n
d. 2n
18. The operation of processing each element in the list is known as ...... D
A. sorting
B. merging
C. inserting
D. traversal
19. Use the breadth first strategy to traverse the graph below A
List the vertices in the order in which breadth first search traverses them.
A. 1,4,5,3,2
B. 1,2,4,3,5
C. 1,3,5,4,2
D. 1,2,3,5,4
20. Which of the following algorithms can be used to most efficiently determine the A
presence of a cycle in a given graph ?
A Depth First Search
B Breadth First Search
C Prim’s Minimum Spanning Tree Algorithm
D Kruskal’ Minimum Spanning Tree Algorithm
21. Traversal of a graph is different from tree because A
A There can be a loop in graph so we must maintain a visited flag for every vertex
B DFS of a graph uses stack, but inorrder traversal of a tree is recursive
C BFS of a graph uses queue, but a time efficient BFS of a tree is recursive.
D All of the above
22. An undirected graph G(V, E) contains n ( n > 2 ) nodes named v1 , v2 ,….vn. Two B
nodes vi ,vj are connected if and only if 0 < |i – j| <= 2. Each edge (vi, vj ) is
assigned a weight i + j. A sample graph with n = 4 is shown below. What will be
the cost of the minimum spanning tree (MST) of such a graph with n nodes?P is
the number of predicate nodes contained in the flow graph G.
A. 1/12(11n^2 – 5n)
B. n^2 – n + 1
C. 6n – 11
D. 2n + 1
23. The length of the path from v5 to v6 in the MST of previous question with n = 10 C
is
A. 11
B. 25
C. 31
D. 41
24. Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry Wij in D
the matrix W below is the weight of the edge {i, j}. What is the minimum possible
weight of a spanning tree T in this graph such that vertex 0 is a leaf node in the
tree T?
A. 7 B. 8 C. 9 D. 10
25. In the graph given in above question, what is the minimum possible weight of a B
path P from vertex 1 to vertex 2 in this graph such that P contains at most 3 edges?
A. 7
B. 8
C. 9
D. 10
26. An undirected graph G has n nodes. Its adjacency matrix is given by an n × n C
square matrix whose (i) diagonal elements are 0‘s and (ii) non-diagonal elements
are 1‘s. which one of the following is TRUE?
(A) Graph G has no minimum spanning tree (MST)
(B) Graph G has a unique MST of cost n-1
(C) Graph G has multiple distinct MSTs, each of cost n-1
(D) Graph G has multiple spanning trees of different costs
27. Consider the following graph: D
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)
28. The Breadth First Search algorithm has been implemented using the queue data C
structure. One possible order of visiting the nodes of the following graph is
(A) MNOPQR
(B) NQMPOR
(C) QMNPRO
(D) QMNPOR
29. In an unweighted, undirected connected graph, the shortest path from a node S to D
every other node is computed most efficiently, in terms of time complexity by
(A) Dijkstra’s algorithm starting from S.
(B) Warshall’s algorithm
(C) Performing a DFS starting from S.
(D) Performing a BFS starting from S.
30. Let G be an undirected connected graph with distinct edge weight. Let emax be C
the edge with maximum weight and emin the edge with minimum weight. Which
of the following statements is false?
(A) Every minimum spanning tree of G must contain emin
(B) If emax is in a minimum spanning tree, then its removal must disconnect G
(C) No minimum spanning tree contains emax
(D) G has a unique minimum spanning tree
31. Let G be an undirected graph. Consider a depth-first traversal of G, and let T be C
the resulting depth-first search tree. Let u be a vertex in G and let v be the first
new (unvisited) vertex visited after visiting u in the traversal. Which of the
following statements is always true? (GATE CS 2000)
(A) {u,v} must be an edge in G, and u is a descendant of v in T
(B) {u,v} must be an edge in G, and v is a descendant of u in T
(C) If {u,v} is not an edge in G then u is a leaf in T
(D) If {u,v} is not an edge in G then u and v must have the same parent in T
32. Consider a weighted complete graph G on the vertex set {v1,v2 ,v} such that the B
weight of the edge (v,,v) is 2|i-j|. The weight of a minimum spanning tree of G is:
(A) n—1
(B) 2n—2
(C) nC2
(D) 2
33. Consider the following graph D
50. Three standards ways of traversing a binary tree T with root R ....... D
A. Prefix, infix, postfix
B. Pre-process, in-process, post-process
C. Pre-traversal, in-traversal, post-traversal
D. Pre-order, in-order, post-order
Module-III
.
Sl. Question Answer
No
1 Which of the following standard algorithms is not a Greedy algorithm? D
(A) Dijkstra’s shortest path algorithm
(B) Prim’s algorithm
(C) Kruskal algorithm
(D) Huffman Coding
2 Which of the following is true about Kruskal and Prim MST algorithms? Assume A
that Prim is implemented for adjacency list representation using Binary Heap and
Kruskal is implemented using union by rank.
(A) Worst case time complexity of both algorithms is same.
(B) Worst case time complexity of Kruskal is better than Prim
(C) Worst case time complexity of Prim is better than Kruskal
(D)none
3 If M=15, n=4, P=(10,10,12,18) and W=(2,4,6,9) of 0/1 knapsack problem then the D
maximum profit is
A. 32
B. 34
C. 36
D. 38
4 The greedy method and dynamic programming algorithm are the methods for D
obtaining ________solution.
A. Correct
B. Incorrect
C. Feasible
D. Optimum
5 which of the following technique is not using for solve a 0-1knapsack problem A
(A) Greedy
(B) Dynamic programming
(C) branch and bound
(D) all of the above
6 the total running time of matrix chain multiplication of n matrices B
(A) ϴ (n4) (B) ϴ (n3) (C) ϴ (n2) (D) ϴ (n)
7 the total running time of optimal binary search tree of n nodes C
(A) O(n2) (B) O(n)
(C) O(n3) (D) O(n log n)
8 If all c(i, j )’s and r(i, j)’s are calculated, then OBST algorithm in worst case takes B
one of the following time.
(a) O(n log n)
(b) O(n3)
(c) O(n2)
(d) O(log n)
9 Let A1, A2, A3, and A4 be four matrices of dimensions 10 x 5, 5 x 20, 20 x 10, and A
10 x 5, respectively. The minimum number of scalar multiplications required to find
the product A1A2A3A4 using the basic matrix multiplication method is
(A) 1500
(B) 2000
(C) 500
(D) 100
10 Four matrices M1, M2, M3 and M4 of dimensions pxq, qxr, rxs and sxt respectively C
can be multiplied is several ways with different number of total scalar
multiplications. For example, when multiplied as ((M1 X M2) X (M3 X M4)), the
total number of multiplications is pqr + rst + prt. When multiplied as (((M1 X M2)
X M3) X M4), the total number of scalar multiplications is pqr + prs + pst.
If p = 10, q = 100, r = 20, s = 5 and t = 80, then the number of scalar multiplications
needed is
(A) 248000
(B) 44000
(C) 19000
(D) 25000
13 The single-source shortest path problem has a good well known solution of the type_ B
A) Bruteforce
B) Greedy
C) DFS
D) Divide and conquer__
__.
14 The single-source shortest path problem is to find shortest paths from a source D
vertex to______________ in the graph.
A) Adjacent vertex
B) Nearest vertex
C) Same vertex
D) All other vertices
A) O(n)
B) O(n2)
C) O(2n)
D) O(logn)
16 The total running time of knapsack problem for a simple approach D
(A) O(n)
(B) O( log n)
(C) 2n logn)
(D) O(2n)
(d) O(nmn).
20 The Knapsack problem where the objective function is to minimize the profit is D
______
(a) Greedy (b) Dynamic 0 / 1
(c) Back tracking (d) Branch & Bound 0/1
21 From the following algorithm design techniques which one is used to find all the C
pairs of shortest distances in a graph?
a. Backtracking
b. Greedy
c. Dynamic programming
d. Divide
22 Let A1, A2, A3, and A4 be four matrices of dimensions 10 x 5, 5 x 20, 20 x 10, and A
10 x 5, respectively. The minimum number of scalar multiplications required to find
the product A1A2A3A4 using the basic matrix multiplication method is
(A) 1500
(B) 2000
(C) 500
(D) 100
23 A path in graph G, which contains every vertex of G once and only once ? B
a. Eulartour
b. Hamiltonian Path
c. Eular trail
d. Hamiltonian tour