Design and Analysis of Algorithms | DAA | MCQ
Question 1
Which of the following statement(s)is / are correct regarding Bellman-Ford shortest path algorithm?
P: Always finds a negative weighted cycle, if one exist s.
Q: Finds whether any negative weighted cycle is reachable
from the source.
Select one:
a. Neither P nor Q
b. Q Only
c. Both P and Q
d. P Only
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: Q Only
[/bg_collapse]
Question 2
what is an optimal Huffman code for alphabet b of the following set of frequencies a: 45, b:13, c:12, d:16, e:9, f:5
Select one:
a. 001
b. 100
c. 111
d. 101
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: 101
[/bg_collapse]
Question 3
Consider the decision problem 2CNFSAT defined as follows:
Select one:
a. NP-hard, but not NP-complete.
b. solvable in polynomial time by reduction to directed graph reachability
c. solvable in constant time since any input instance is satisfiable.
d. NP-Complete.
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: solvable in polynomial time by reduction to directed graph reachability
[/bg_collapse]
Question 4
In flow networks Residual capacity Cf (u,v)=
Select one:
a. f(u, v) – c(u,v)
b. s(u,v) – t(u, v)
c. t(u,v) – s(u,v)
d. c(u,v) – f(u,v)
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: c(u,v) – f(u,v)
[/bg_collapse]
Question 5
In Ford-Fulkerson algorithm, flow of the augmenting path is selected based on
Select one:
a. cf(p) =min{ cf (u,v):(u,v)is in p }
b. cf(p) =min{ cf (u,v):(u,v)is in f-P }
c. cf(p) =max{ cf (u,v):(u,v)is in f-P }
d. cf(p) =max{ cf (u,v):(u,v)is in p }
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: cf(p) =min{ cf (u,v):(u,v)is in p }
[/bg_collapse]
Question 6
Ram and Shyam have been asked to show that a certain problem Π is NP-complete. Ram shows a polynomial time reduction from the 3-SAT problem to Π, and Shyam shows a polynomial time reduction from Π to 3-SAT. Which of the following can be inferred from these reductions ?
Select one:
a. Π is NP-complete
b. Π is in NP, but is not NP-complete
c. Π is neither NP-hard, nor in NP
d. Π is NP-hard but not NP-complete
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: Π is NP-complete
[/bg_collapse]
Question 7
To implement Dijkstra’s shortest path algorithm on unweighted graphs so that it runs in linear time, the data structure to be used is:
Select one:
a. Heap
b. Stack
c. B-Tree
d. Queue
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: Queue
[/bg_collapse]
Question 8
Match the following
Group A Group B
a) Dijkstra’s single shortest path p) Dynamic Programming
b) Bellmen Ford’s single shortest path algorithm q) Backtracking
c) Floyd Warshell’s all pair shortest path algorithm r) Greedy Algorithm
Select one:
a. a-p, b-p, c-p
b. a-p, b-r, c-q
c. a-r, b-q, c-p
d. a-r, b-p, c-p
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: a-r, b-q, c-p
[/bg_collapse]
Question 9
| Items | wi | vi |
| Item1 | 5 pounds | 30$ |
| Item2 | 10 pounds | 20$ |
| Item3 | 20 pounds | 100$ |
| Item4 | 30 pounds | 90$ |
| Item5 | 40 pounds | 160$ |
The knapsack can hold 60 pounds find the optimal solution
Select one:
a. 260 $
b. 290$
c. 270 $
d. 250$
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: 260 $
[/bg_collapse]
Question 10
Consider the following two problems of graph.
1) Given a graph, find if the graph has a cycle that visits every vertex exactly once except the first visited vertex which must be visited again to complete the cycle.
2) Given a graph, find if the graph has a cycle that visits every edge exactly once. Which of the following is true about above two problems
Select one:
a. Both problems belong to P set
b. Both problems belong to NP complete set
c. Problem 1 belongs to P set and 2 belongs to NP Complete set
d. Problem 1 belongs NP Complete set and 2 belongs to P
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: Problem 1 belongs NP Complete set and 2 belongs to P
[/bg_collapse]
Question 11
Find the Running Time of the fastest algorithm to calculate the shortest path between any two vertices of a graph where all edges have equal weights.
Select one:
a. 0 (E+V)
b. 0(V log2V+E )
c. 0 (V+E) log2V
d. 0(V log V2+E)
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: 0 (E+V)
[/bg_collapse]
Question 12
The time required to find shortest path in a graph with n vertices and e edges is
Select one:
a. O (e)
b. O (n)
c. O (n2)
d. O (e2)
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: O (n2)
[/bg_collapse]
Question 13
In an unweighted, undirected connected graph, the shortest path from a node S to every other node is computed most efficiently, in terms of time complexity by
Select one:
a. Warshall’s algorithm
b. Dijkstra’s algorithm starting from S.
c. Performing a BFS starting from S
d. Performing a DFS starting from S.
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: Performing a BFS starting from S
[/bg_collapse]
Question 14
A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0.
We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:
l(i,j) = 0, if either i=0 or j=0
= expr1, if i,j > 0 and X[i-1] = Y[j-1]
= expr2, if i,j > 0 and X[i-1] != Y[j-1]
Select one:
a. expr2 ≡ max(l(i-1, j), l(i, j-1))
b. expr2 ≡ max(l(i-1,j-1),l(i,j))
c. expr1 ≡ l(i-1, j) + 1
d. expr1 ≡ l(i, j-1)
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: expr2 ≡ max(l(i-1, j), l(i, j-1))
[/bg_collapse]
Question 15
Four matrices M1, M2, M3 and M4 of dimensions pxq, qxr, rxs and sxt respectively 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
Select one:
a. 19000
b. 44000
c. 248000
d. 25000
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: 19000
[/bg_collapse]
Question 16
For 0/1 KNAPSACK problem, the algorithm takes ________ amount of time for memory table, and ______time to determine the optimal load, for N objects and W as the capacity of KNAPSACK.
Select one:
a. O(NW), O(N+W)
b. O(N), O(NW)
c. O(N+W), O(NW)
d. O(NW), O(N)
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: O(NW), O(N+W)
[/bg_collapse]
Question 17
Match the following:
List – I List – II
1 Quick Sort a Divide and Conquer
2 Graph colouring b Greedy
3 String editing c Dynamic Programming
4 Prim’s Algorithm d Back tracking
Select one:
a. 1-b, 2-a, 3-d, 4-c
b. 1-a, 2-d, 3-c, 4-b
c. 1-a, 2-c, 3-b, 4-d
d. None of these
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: 1-a, 2-d, 3-c, 4-b
[/bg_collapse]
Question 18
kruskal’s algorithm uses——– and prim’s algorithm uses—— in determining the MST
Select one:
a. edges,vertex
b. vertex,vertex
c. edges,edges
d. vertex,edges
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: edges,vertex
[/bg_collapse]
Question 19
If all c(i, j )’s and r(i, j)’s are calculated, then OBST algorithm in worst case takes one of the following time.
Select one:
a. O(log n)
b. O(n3)
c. O(n log n)
d. O(n2)
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: O(n3)
[/bg_collapse]
Question 20
A simple Graph G = L U R, set of 2 non-empty vertices and each vertex from L has an edge to atleast one vertex of R, is called as
Select one:
a. Flow-network graph
b. Bipartite Graph
c. Complete graph
d. Bifocal graph
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ] Feedback: Bipartite Graph
[/bg_collapse]