Design Analysis Algorithm
Design Analysis Algorithm
BCA
1. 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.
(a) O(n log n) (b) O(n3) (c) O(n2) (d) O(log n) (e) O(n4).
Ans : O(n3)
2. For a 15-puzzle problem let the initial arrangement be the following one,
then answer the questions 4 7 with the following arrangement.
10 13 15 7
9 1 4 14
12 8 6
11 2 5 3
Ans : 1
6. What do you call the selected keys in the quick sort method?
(a) Outer key (b)Inner Key (c) Partition key(d) Pivot key (e) Recombine key.
Ans :
11. In analysis of algorithm, approximate relationship between the size of the job and
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 (e) Order of Storage.
Ans : log2 n + 1
13. For defining the best time complexity, let f (n) = log n and g (n) = n, _________
(a)f (n) (g(n)), but g(n) (f(n)) (b) f (n) (g(n)), but g(n) (f(n))
(c)f (n) (g(n)), and g(n) (f(n)) (d) f (n) (g(n)), and g(n) (f(n))
15. Let f, t: NR 0, and t (n) O (f (n)) iff t(n) c.f (n) where cis positive real
constant andn no, then no is ___________
(a) Upper bound (b)Lower bound (c) Duality value
(d) Threshold value (e) Maximum value.
Ans :3
18. Which method of traversal does not use stack to hold nodes that are waiting to be
processed?
(a) Dept First (b) D-search (c)Breadth first
(d) Back-tracking
19. The Knapsack problem where the objective function is to minimize the profit is
______
(a) Greedy (b) Dynamic 0 / 1 (c) Back tracking
(d) Branch & Bound 0/1
21. The Hamiltonian cycles problem uses the following line of code to generate a
next vertex, provided x[ ] is a global array and kth vertex is under consideration:
(a) x[k] (x[k] + 1) mod n (b) x[k] (x[k]) mod (n)
(c) x[k] (x[k] + 1) mod (n+1) (d) x[k] x[k+1] mod n
Ans :O(nmn).
23. 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.
(a) O(N+W), O(NW) (b) (NW),O(N+W) (c)O(N),O(NW) (d) O(NW),O(N)
Ans :Deletion
25. What is the type of the algorithm used in solving the 8 Queens problem?
(a)Backtracking (b) Dynamic (c) Branch and Bound (d) DandC
Ans :Backtracking
26. The following are the statements regarding the NP problems. Chose the right option
from the following options:
I. All NP-complete problems are not NP-hard.
II. SomeNP-hard problems are not known to be NP-complete.
(a) Both (I) and (II) are true
(b) Both (I) and (II) are false
(c) Only (I) is true
(d) Only (II) is true
27. Let G be a graph with n nodes and let m be the chromatic number of the graph.
Then the time taken by the backtracking algorithm to color it is
(a) O(nm)
(b) O(n+m)
(c) O(mnm)
(d) O(nmn).
Ans :O(nmn).
28. The time complexity of the shortest path algorithm can be bounded by
(a) O(n2)
(b) O(n4)
(c) O(n3)
(d) O(n)
(e) O(n log n ).
Ans :O(n3)
29. Read the following statements carefully and pick the correct option:
I. The worst time complexity of the Floyds algorithm is O(n3). II.
The worst time complexity of the Warshalls algorithm is O(n3).
(a) (I) is false but (II) is true
(b) (I) is true but (II) is false
(c) Both (I) and (II) are true
(d) (I) is true and (II) is not true always
(e) Both (I) and (II) are false.
Ans :Equivalence
31. For the bubble sort algorithm, what is the time complexity of the best/worst case?
(assume that the computation stops as soon as no more swaps in one pass)
(a) best case: O(n) worst case: O(n*n)
(b) best case: O(n) worst case: O(n*log(n))
(c) best case: O(n*log(n)) worst case: O(n*log(n))
(d) best case: O(n*log(n)) worst case: O(n*n)
32. For the quick sort algorithm, what is the time complexity of the best/worst case?
(a) best case: O(n) worst case: O(n*n)
(b) best case: O(n) worst case: O(n*log(n))
(c) best case: O(n*log(n)) worst case: O(n*log(n))
(d) best case: O(n*log(n)) worst case: O(n*n)
33. In an arbitrary tree ( not a search tree) of order M. Its size is N, and its height is K.
The computation time needed to find a data item on T is
(a) O(K*K)
(b) O(M*M)
(c) O(N)
(d) O(K)
Ans : O(N)
35. If f,t: N R+, then t (n) (f (n)), iff f(n) O (t (n)) is known as
(a) Limit rule
(b) Rule of inference
(c) Duality rule
(d) Rule of consequences
36. The time taken by NP-class sorting algorithm is
(a) O(1)
(b) O(log n)
(c) O(n2)
(d) O(n)
Ans :O(n)
37. Find the odd one out from the following categories of algorithms.
(a) TVSP
(b) N-Queens
(c) 15-Puzzle
(d) Bin-Packing.
Ans : Bin-Packing.
38. The time complexity of binary search in best, worst cases for an array of size N is
(a) N, N2
(b) 1, Log N
(c) Log N, N2
(d) 1, N log N
Ans : 1, Log N
39. Which of following algorithm scans the list by swapping the entries whenever pair
of adjacent keys are out of desired order?
(a) Insertion sort
(b) Quick sort
(c) Shell sort
(d) Bubble sort
40. The mathematical definition for Omega can be defined as, provided f,g:NR+ and c is
a positive constant and n > n0,
(a) f(n) c. g(n) n
(b) f(n) = c. g(n) n
(c) f(n) c + g(n) n
(d) f(n) = c + g(n) n
44. Identify the name of the sorting in which time is not proportional to n2.
(a) Selection sort
(b) Bubble sort
(c) Qucik sort
(d) Insertion sort.
45. The optimal solution to a problem is a combination of optimal solutions to its sub-
problems. This is known as
(a) Principleof Duality
(b) Principle of Feasibility
(c) Principle of Optimality
(d) Principle of Dynamicity.
46. Which of the following versions of merge sort algorithm does uses space efficiently?
(a) Contiguous version
(b) Array version
(c) Linked version
(d) Structure version
(e) Heap version.
48. How many edges are there in a Hamiltonian cycle if the edge cost is c and the
cost of cycle is cn
(a)c (b) cn
(c)n (d) 2c
Ans :n.
Ans : L NP
50. What would be the cost value for any answering node of a sub tree with root r
using branch-bound algorithm?
(a) Maximum
(b) Minimum
(c) Optimal
(d) Average
Ans: Minimum
51. Name the node which has been generated but none of its children nodes have
been generated in state space tree of backtracking method.
(a) Dead node
(b) Live node
(c) E-Node
(d) State Node
Ans: Livenode
52. How many nodes are there in a full state space tree with n = 6?
(a) 65
(b) 64
(c) 63
(d) 32
Ans : 63
53. This algorithm scans the list by swapping the entries whenever pair of
adjacent keys are out of desired order.
(a) Insertion sort.
(b) Bubble sort.
(c) Shell sort.
(d) Quick sort.
Ans: Transitive
55. From the following chose the one which belongs to the algorithm paradigm
other than to which others from the following belongs to.
(a) Minimum & Maximum problem.
(b) Knapsack problem.
(c) Selection problem.
(d) Merge sort.
56. To calculatec(i, j )s, w( i, j)s and r(i, j)s; the OBST algorithm in worst case takes
the following time.
(a) O(log n)
(b) O (n4)
(c) O (n3)
(d) O (n log n)
Ans: O (n3)
57. What is the type of the algorithm used in solving the 4 Queens problem?
(a) Greedy
(b) Dynamic
(c) Branch and Bound
(d) Backtracking.
Ans: Backtracking.
58.In Knapsack problem, the best strategy to get the optimal solution, where Pi, Wi is the
Profit, Weight associated with each of the Xith object respectively is to
(a) Arrange the values Pi/Wi in ascending order
(b) Arrange the values Pi/Xi in ascending order
(c) Arrange the values Pi/Wi in descending order
(d) Arrange the values Pi/Xi in descending order
Ans: O(N)
60.The divide and conquer merge sort algorithms time complexity can be defined as
(a) (long n)
(b) (n)
(c) (n log n)
(d) (n log n)
Ans: (n log n)
61. In analysis of algorithm, approximate relationship between the size of the job and
the amount of work required to do it is expressed by using
(a) Order of magnitude or Big - O
(b) Central tendency
(c) Differential equation
(d) Polynomial equation
65. Which of the following searching methods requires that all keys must reside
in internal memory?
(a) Binary search
(b) Sequential search
(c) Hashing
(d) Depth first search
66. Which of the following formulas in Omega notation best represent the expression
n+35n+6?
(a) (n) (b) (n) (c) (n) (d) (35)
Ans: (n)
Ans: Linear.
70. Which of the following are essential statement types for describing algorithms?
(a) Sequence (b) Selection (c) Repetition (d) All the above
71. When we say an algorithm has a time complexity of O (n), what does it mean?
(a) The algorithm has n nested loops
(b) The computation time taken by the algorithm is proportional to n
(c) The algorithm is n times slower than a standard algorithm
(d) There are n number of statements in the algorithm
72. Can we read a data item at any location of a list within a constant time (i.e.
O(1))?
(a) Yes
(b) Yes, only if the list is implemented by pointers (i.e. linked-list)
(c) Yes, only if the list is implemented by an array
(d) No, we need O(n) computation steps no matter what kind
of implementation is used
Ans: Yes, only if the list is implemented by an array
73. Sequential search has a time complexity of O(n), and binary search has a time
complexity of O(log(n)). What difference will it make when the size n is 1000?
(a) You would not notice much difference because computers run very fast
anyway
(b) As n is 1000, binary search is twice as fast as sequential search
(c) As n is 1000, binary search is 10 times as fast as sequential search
(d) As n is 1000, binary search is 100 times as fast as sequential search.
74. Readthe following statements carefully, and choose the correct answer.
I. The notation is Anti Symmetric.
II. The big Oh notation is Semi Equivalence.
(a) (I) is FALSE but (II) is TRUE (b) Both (I), (II) are TRUE
(c) (I) is TRUE but(II) is FALSE (d) Both (I), (II) are FALSE
Ans:Merge Sort
76. How many minimum number of spanning trees, one can have from a given
connected graph with N nodes is having different weights for the edges.
(a)N-1 (b) One (c) 1/(N+1) 2NCN (d) 2NCN
Ans: one
77. The mathematical definition for Omega can be defined as, provided f,g:NR+ and c
is a positive constant and n > n0,
(a) f(n) c. g(n) n
(b) f(n) c. g(n) n
(c) f(n) c + g(n) n
(d) f(n) c + g(n) n
(e) f(n) g(n) n.
Ans:f(n) c. g(n) n
78. The OBST algorithm in worst case takes _______ time if all c(i, j )s and r(i, j)s are
calculated.
(a) O(log n) (b) O(n4) (c) O(n3) (d) O(n log n)
Ans: O(n3)
80. Breadth first search uses __________ as an auxiliary structure to hold nodes for
future processing.
(a) Stack (b) Linked list (c) Graph (d) Queue.
Ans : Queue
81. From the following pick the one which does not belongs to the same paradigm to which
others belongs to.
(a) Minimum & Maximum problem
(b) Knapsack problem
(c) Selection problem
(d) Merge sort
Ans:Knapsack problem
85. __________ is the minimum number of steps that can executed for the given
parameters
a. Average case c. Worst case
b. Time complexity d. Best case
Ans: Best case
86. __________ is the maximum number of steps that can executed for the given
parameters
Ans:Worst case
87. __________ is the average number of steps that can executed for the given
parameters
a. Average case c. Worst case
b. Time complexity d. Best case
Ans: Average Case
88. Testing of a program consists of 2 phases which are ______________________
and ____________
a. Average case & Worst case b. Time complexity & Space complexity
c. Validation and checking errors d. Debugging and profiling
Ans: (logn)
Ans: (logn)
a. O(n2log7) c. O(nlogn)
b. O(n2) d. O(logn)
Ans : O(n2)
Ans : O(nlogn)
97. Which design strategy stops theexecution when it find the solution otherwise starts
the problem from top
a. Back tracking c. Divide and conquer
b. Branch and Bound d. Dynamic programming
Ans : Write
100. In pseudo-code conventions output express as __________
a. input c. Read
b. Write d. Return
Ans : Read
101. Performance based criteria of algorithm , which has to do with its computing time is
_______________
a. Time Complexity c. Input
b. Space Complexity d. Finiteness
Ans : Quadratic
110. The method will choosing when sub problems share sub problems
a. Divideand conquer c. Greedy method
b. Dynamic programming d. Back tracking
a. 2n2+4n+4 c. 2n2+n
b. 2n2+4n+2 d. 2n2-1
Ans : 2n2+4n+2
112. The sorting , which works very well for small file is ______________
a. Count sort c. Selection sort
b. Merge sort d. Quick sort
Ans : Algorithm
115. Advantage of finding maximum and minimum using divide and conquer method
instead of using conditional operators is __________________
a. Reduce Space complexity c. Get accurate value
b. Reduce Time complexity d. Simple calculations
116. Given two non-negative functions f(n)= 5n2+6n+1 and g(n)=n2 . Calculate upper
bound value ,C
a. C=5 c. C=12
b. C=6 d. C=11
Ans : C=12
117. Given two non-negative functions f(n)= 6n2+5n+1 and g(n)=n2 . Calculate lower bound
value ,C
a. C=5 c. C=12
b. C=6 d. C=11
Ans : C=6
118. The functions f &g are non-negative functions. The function f(n)=O(g(n)) if and only
if there exist positive constants c& n0 such that __________ for all n, n n0
a. f(n)C*g(n) c. f(n) = C*g(n)
b. f(n) C*g(n) d. f(n) != C*g(n)
119. The functions f & g are non-negative functions. The function f(n)=(g(n)) if and only
if there exist positive constants c& n0 such that ___________ for all n, n n0
a. f(n) C*g(n) c. f(n) = C*g(n)
b. f(n) C*g(n) d. f(n) != C*g(n)
Ans :
Ans : O
Ans :
127. The general criteria of algorithm; at least one quantity is produced ______
a. Output b. Finiteness
b. Effectiveness d. Input
Ans : Output
128. The general criteria of algorithm; Each instruction is clear and unambiguous ______
a. Output b. Definiteness
b. Effectiveness d. Input
Ans : Definiteness
129. The general criteria of algorithm; algorithm must terminates after a finite number
of steps ______
a. Output b. Finiteness
b. Effectiveness d. Input
Ans : Finiteness
a. 4n+4 c. 4n2+4
b. 2n2+2n+2 d. 4n+4
Ans : 4n+4
a. 6n2-14n+4 c. 4n2+6n+12
b. 6n2+14n+10 d. 6n2-14n+10
Ans :6n2-14n+10
137. Cost of minimum spanning tree , from the following diagram is ____________
a 23 d 12
10 11
20 4 f
c 7 h
6 17
2 e
b
16
a. 40 c. 41
b. 39 d. 47
Ans. 40
138. which is not feasible solution in the case of job sequence problem
item : 1 2 3 4
profit : 100 10 15 27
deadline : 2 1 2 1
a. (1,4) c. (4,3)
b. (2,4) b. (1,2)
Ans. (2,4)
139. which isoptimal value in the case of job sequence problem
item : 1 2 3 4 5
profit : 20 15 10 5 1
deadline : 2 2 3 3 3
a. (1,3,4) c. (4,2,3)
b. (1,2,4) d. (1,5,2)
Ans. (1,2,4)
140. which is optimal value in the case of job sequence problem
item : 1 2 3 4 5 6 7
profit : 3 5 20 18 1 6 30
deadline : 1 3 4 3 2 1 2
a. (1,5,6,4) c. (7,6,4,3)
b. (2,3,1,7) b. (1,2,3,4)
Ans. (7,6,4,3)
141. 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 c. 480
b. 499 d. 485
Ans. 498
142. which is optimal value in the case of fractional knapsack problem, capacity of
knapsack is 10
item : 1 2 3 4 5
profit : 12 32 40 30 50
weight : 4 8 2 6 1
a. 345 c. 384
b. 354 d. 350
Ans. 354
144. In the case of Fibnocci heap the running time of Prim's algorithm is _________
a. O(E log V)
b. O(V log E)
c. O( log V)
d. O(E log E)
Ans. O(E log V)
145. Time complexity of 4-queen problem
a. O(|V|)
b. O(|E|)
c. O(|V|+|E|)
d. O(|V2|)
Ans.O(|V|+|E|)
146. If the graph is represented as an adjacency matrix then the time complexity
of Kruskal's algorithm is ____________
a. O(E log V)
b. O(VlogE)
c. O(V2)
d. O(logE)
Ans. O(E log V)
147. BFS is best compared to DFS in the case of ________________
a. The graphs width is large
b. The graphs depth is large
c. The graph consists of many nodes
d. The graph is complex
Ans. The graphs depth is large
148. The timecomplexity of Strassen's algorithm is ___________
a. O(E log V)
b. O(V2)
c. O(nlog7)
d. O(log n7)
Ans. O(nlog7)
149. By Strassen's equation what is wrong in the following equation
a. p1=(a+d)(e+h) c. c.p3=(a-c)(e+f)
b. b.p2=(-e+g)d d. d.p4=(a+b)h
Ans. p2=(-e+g)d
150. By Strassen's equation what is wrong in the following equation
a. p1=(a+d)(e+h) c. c.p3=(a-c)(e+f)
b. b.p7=(-e+g)d d. d.p4=(a-b)h
Ans. p4=(a-b)h
151. The advantage of selecting maxmin algorithm using divide and conquer
method compared to staightmaxmin algorithm is _____
a. Less time complexity c. High accuracy
b. Less space complexity d. High time complexity
152. The number of comparisons of elements for best case is ____________ in the case
of maxmin algorithm based on divide and conquer method
a. 3n/2 c. n/4
b. n/2 d. n-1
ans. 3n/2
153. The number of comparisons of elements for average case is ____________ in the
case of maxmin algorithm based on divide and conquer method
a. 3n/2 c. n/4
b. n/2 d. n-1
ans. 3n/2
154. The number of comparisons of elements for worst case is ____________ in the case
of maxmin algorithm based on divide and conquer method
a. 3n/2 c. n/4
b. n/2 d. n-1
ans. 3n/2
155. The method which stops the execution ,if it find the solution. Otherwise it start from
the top
a. Branch and bound c. Dynamic programming
b. Back tracking d. Divide and conquer
Ans. Back tracking
156. Which is not return optimal solution from the following methods
a. Dynamic programming c. Backtracking
b. Branch and bound d. Greedy method
Ans. Backtracking
157. In the case ofsub problems share sub problems ,which method is suitable
a. greedy method c. branch and bound
b. dynamic programming d. divide and conquer
ans. Dynamic programming
158. The method which return different solutions from a single point ,which is
_________
a. greedy method c. branch and bound
b. dynamic programming d. divide and conquer
ans. Greedy method
159. ByQuicksortalgorithm from where is first partition done in the following array
2 8 7 1 3 5 6 4
a. 5 c. 3
b. 4 d. 1
Ans. 3
164. The files x1,x2,x3 are 3 files of length 30,20,10 records each. What is the optimal
merge pattern value?
a. 110 c. 60
b. 90 d. 50
Ans. 90
Ans : //
Ans : Profiling
170. In Algorithm Specification the blockes are indicated with matching _______
a. Braces c. Square Brackets
b. Parenthesis d. Slashes
Ans : Braces
171. Huffmancodes are the applications of _________ with minimal weighted external
path length obtained by an optimal set.
a. BST b. MST
c. Binary tree d. Weighted Graph
173. ____________ is an algorithm design method that can be used when the solution
to a problem can be viewed as the result of a sequence of decisions
175. The term ________ refers to all state space search methods in which all hildren of
the nodes are generated before any other live node can becomethe E-node.
a. Backtacking c. Depth First Search
b. Branch and Bound d. Breadth First Search
176. A __________ is a round trip path along n edges of G that visits every vertex once
and returns to its starting position.
a. MST c. TSP
b. Multistage Graph d. Hamiltonian Cycle
Ans : Backtracking
Ans : binary search algorithm is not efficient when the data elements are more than 1000.
182. The space factor when determining the efficiency of algorithm is measured by
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 Ans: Counting the maximum memory needed by
the algorithm
183. Which of the following case does not exist in complexity theory
a. Best case c. Average case
b. Worst case d. Null case
Ans : Null Case
a. O(n) c. O(n2)
b. O(log n) d. O(n log n)
Ans : O(n2)
Ans : Recursion
193. The running time of quick sort depends heavily on the selection of
a. No of inputs c. Size o elements
b. Arrangement of elements in array d. Pivot element
Ans :O(n+k)
Ans : Small
197. Quick sort is based on divide and conquer paradigm; we divide the problem on base
of pivotelementand:
a. There is explicit combine process as well to conquer the solution.
b. No work is needed to combine the sub-arrays, the array is already sorted
c. Merging the subarrays
d. None of above.
Ans:Greedy Technique
Ans:Kruskal's algorithm (choose best non-cycle edge) is better than Prim's (choose best
Tree edge) when the graph hasrelatively few edges )