Cs502 Final Term Solved Mcqs by Junaid
Cs502 Final Term Solved Mcqs by Junaid
10 70
20 20
30 80
70 200
i. 90
ii. 280
iii. 200
iv. 100
6. In activity scheduling algorithm, each activity is represented by a
i. Rectangle
ii. Square
AL-JUNAID TECH INSTITUTE
iii. Circle
iv. Triangle
7. Those problems in which greedy finds good, but not always best is called a greedy…..
i. Heuristic
ii. Solution
iii. Result
iv. Algorithm
8. The knapsack problem belongs to the domain of…..Problems
i. Searching
ii. Sorting
iii. Linear solution
iv. Optimization
9. The general coin change problem can be solved using
i. Recursion
ii. Greedy algorithm
iii. Dynamic programming
iv. Divide and conquer
10. Huffman algorithm produces the…………prefix code tree
i. Optimal
ii. Better
iii. Best
iv. Worst
11. Huffman algorithm generates an optimum …..code
i. Postfix
ii. Infix
iii. None of the given options
iv. Prefix
12. …..ways of representing graphics
i. 1
ii. 2
iii. 3
iv. 4
13. Knapsack word originates from ……language
i. German
ii. English
iii. French
iv. Norwegian
14. Graphs are important…….model for many application problems
i. Mathematical
ii. Unpredictable
iii. Haphazard
iv. Unsystematic
15. Which type of algorithm is harder to prove the correctness?
i. Dynamic
AL-JUNAID TECH INSTITUTE
ii. Greedy
iii. Divide and conquer
iv. Brute force
16. …..Items are not allowed in 0/1 knapsack problem
i. Fractional
ii. 0
iii. 1
iv. 0/1
17. Matrix multiplication is a(n)……..operation
i. Nether commutative nor associative
ii. Transitive
iii. Commutative
iv. Associative
18. For a Diagraph G= (V.E), Sum of in-degree (v) -----------------.
• Traversed tree
• Simple tree
• Free tree
20. Using ASCII code, each character is represented by a fixed-length code of-------------bits per
character.
• 4
• 6
10
• 8 pg#100 21. In Knapsack Problem, the goal is to put items in the Knapsack
such that the value of the items is---------
• Decreased
• Maximized pg#109
• 70 bits
• 60 bits
• 90 bits
• 72 bits
• No cycles pg#116
24. The number of edges that come out of a vertex is called the-------------of that vertex in the
digraph.
• Post-degree
• in-degree
• out-degree pg#114
• pre-degree
25. If Matrix-A has dimensions “3x2” and Matrix-B has dimensions “2x3”, then multiplication of
Matrix-A and Matrix-B will result a new Matrix-C having dimensions.
• 3x2
• 2x3
• 2x2
• 3x3pg#87
26. A/an----------is one in which you want to find, not just a solution, but the best solution.
AL-JUNAID TECH INSTITUTE
• Optimization problem
• NP complete problem
• Best problem
27. Fractional Knapsack is founded on-----------method.
• Recursive
• Dynamic programming
28. If the graph is represented using an adjacency matrix, then Breadth-first search takes-----------
-time.
• O(E+1)
• O(V^2)
• O(V)
• O(E)
• Median, Mode
• Recursive, Iterative
• Sequentially, Parallel
• Memorization programming
• Edit-distance programming
31. In Huffman encoding, the---------is the number of occurrences of a character divided by the
total characters in the message.
• Counting
• Parsing
• Weight
32. The Binary Tree constructed by a Huffman Encoding is a:
• Spelling correction
• Ascending order
• 18
• 32
• 24
• 30
35. In ------------- Knapsack Problem, limitation is that an item can either be put in the bag or
not. Fractional items are not allowed.
a. 0
b. 1
c. 0/1 pg#91
d. Fractional
AL-JUNAID TECH INSTITUTE
36. An in-place sorting algorithm is one that-----------uses additional array for storage.
• Always
• Permanently
• Sometime
37. If Matrix-A has dimensions “pxq” and Matrix-B has dimensions “qxr”, then multiplication of
Matrix-A and Matrix-B will result a new Matrix-C having dimensions.
• Pxq
• Pxr page#84
• qxr
• qxp
• K is large
• K is small pg#71
• None
39. When matrix A of 5x 3 is multiply with matrix B of 3x 4 then the multiplication required is:
• 15
• 12
• 36
• 60
40. -------------is a linear time sorting algorithm.
• Merge sort
• Quick sort
AL-JUNAID TECH INSTITUTE
• Bubble sort
• Radix sort
41. In Dynamic Programming approach, we do not store the solution to each sub problem in case
if it reappears.
• True
• False page#75
42. Dynamic Programming approach is usually useful in solving optimization problem.
• True page#97
• False
43. Which of the following algorithm provides an optimal solution for the activity selection
problem?
• Brute force
• Greedy pg#105
• Recursive
44. A graph is---------- if every vertex can reach every other vertex.
Connected pg#116
• Cycle
• Acyclic
• Loop
45. In a Huffman encoding when a new node is created by combining two nodes, the new node
is placed in the ________.
• Linked list
• Graph traversal
46. Huffman algorithm produces the _________ prefix code
• Optimal pg#105
AL-JUNAID TECH INSTITUTE
• Best
• Worst
• Better
47. In ________ algorithm, you hope that by choosing a local optimum at each step, you will end
up a global
optimum.
• Simple
• Greedy pg#97
• Brute Force
48. The string “Imncde” is coded with ASCII code, the message length would be ____ bits.
• 24
• 36
• 48
• 60
49. For graph traversal, breadth-first search strategy _________
• Is always recursive
• Cannot br recursive
• Cannot be non-recursive
• Is always ignored
• Should be maximized
51. If the graph is represented using an adjacency list, then Breadth-first search takes--------- time
• O(V^2)
AL-JUNAID TECH INSTITUTE
• O(V)
• O(V+E) pg#138
• O(E+1)
52. Suppose you are given infinite coins of 1,2 ,3, and 4.Select the ways of the minimum number
of coins that required to achieve a sum of 6:
• 1
• 2 Conceptual
• 3
• 4
53. sing ASCII standard the string “greedy” will be encoded with
• 48 bits Conceptual
• 120 bits
• 44 bits
• 40 bits
54. The Huffman codes provide a method of -------data efficiency.
• Reading/Writing
• Encoding/Decoding pg#99
• Divide/Conquer
• Inserting/Deleting
55. In the context of activity selection algorithm, time s dominated by sorting of the activities by-
-----
• Start Times
• Average Times
AL-JUNAID TECH INSTITUTE
• CPU Burst Times
• Number of items
• Capacity of the knapsack
57. The greedy approach gives us an optimal solution when the coins are all powers of a --------
denomination
• Fixed pg#98
• Variable
• Constant
• Static
58. In Activity Selection, we say that two activities are non-interfering if their start-finish
interval-------overlap
• Do
• Do not pg#105
• Sometimes
• Once
59. How many steps are involved to design the dynamic programming strategy?
• 2
• 3
• 1
• 4 pg#92
60. Bag is a-------------------
• compiler
61. If a problem is in NP-complete, it must also be in NP.
► True page#170
► False
62. The Huffman algorithm finds a optimal solution.
► True pg#105
► False
63. The Huffman algorithm finds an exponential solution
► True
► False pg#105
64. The Huffman algorithm finds a polynomial solution
► True google
► False
65. The greedy part of the Huffman encoding algorithm is to first find two nodes
with smallest frequency.
► True pg#100
► False
66. The code word assigned to characters by the Huffman algorithm have the property that no
code word is the prefix of any other.
► True pg#101
► False
67. Huffman algorithm uses a greedy approach to generate a postfix code T that minimizes the
expected length B (T) of the encoded string.
► True
► False pg#102
68. Dijkestra’s single source shortest path algorithm works if all edges weights are non-negative
and there are negative cost cycles.
► True
► False pg#154
AL-JUNAID TECH INSTITUTE
69. The term “coloring” came form the original application which was in architectural design.
► True
► False pg#176
70. In the clique cover problem, for two vertices to be in the same group, they must be adjacent to
each other.
► True pg#176
► False
71. Dijkstra’s algorithm is operates by maintaining a subset of vertices
► True pg#155
► False
72. We do sorting to,
► keep elements in random positions
► keep the algorithm run in linear order
► keep the algorithm run in (log n) order
73. After partitioning array in Quick sort, pivot is placed in a position such that
► Values smaller than pivot are on left and larger than pivot are on right pg#48
► Values larger than pivot are on left and smaller than pivot are on right
Pivot is the first element of array
► False
75. A p × q matrix A can be multiplied with a q × r matrix B. The result will be a p × r matrix C.
There are (p . r) total entries in C and each takes _________ to compute.
► O (q) pg#84
► O (1)
► O (n2)
► O (n3)
76. One of the clever aspects of heaps is that they can be stored in arrays without using any
_______________.
AL-JUNAID TECH INSTITUTE
Pointers pg#40
constants
variables
functions
77. Merge sort requires extra array storage,
True pg#54
False
78. The Huffman codes provide a method of encoding data inefficiently when coded using
ASCII standard.
True
False pg#99
79. Using ASCII standard the string abacdaacac will be encoded with __________ bits.
80 pg#99
160
320
100
80. Using ASCII standard the string abacdaacac will be encoded with 160 bits.
True
False pg#99
81. Using ASCII standard the string abacdaacac will be encoded with 10 bytes.
True
False pg#99
82. The greedy part of the Huffman encoding algorithm is to first find two nodes with
character frequency
True
False
83. Huffman algorithm uses a greedy approach to generate an prefix code T that minimizes
True pg#100
False
► False
► unknown pg#173
87. What is generally true of Adjacency List and Adjacency Matrix representations of graphs?
► Lists require less space than matrices but take longer to find the weight of an edge
(v1,v2) pg#116
► Lists require less space than matrices and they are faster to find the weight of an edge (v1,v2)
► Lists require more space than matrices and they take longer to find the weight of an edge
(v1,v2)
► Lists require more space than matrices but are faster to find the weight of an edge (v1,
88. If a graph has v vertices and e edges then to obtain a spanning tree we have to delete
► v edges.
► v – e + 5 edges
► v + e edges.
► None of these
89. Maximum number of vertices in a Directed Graph may be |V 2|
► True
► False pg#115
90. The Huffman algorithm finds a (n) _____________ solution.
► Optimal pg#105
► Non-optimal
► Exponential
► Polynomial
91. The Huffman algorithm finds an exponential solution
► True
► False pg#115
► Values larger than pivot are on left and smaller than pivot are on right
► False
95. In counting sort, once we know the ranks, we simply _________ numbers to their final
positions in an output array.
► Delete
► copy Page# 57
► Mark
► arrange
96. . Dynamic programming algorithms need to store the results of intermediate sub-problems.
► True pg#75
► False
97. . A p × q matrix A can be multiplied with a q × r matrix B. The result will be a p × r matrix C.
There are (p . r) total entries in C and each takes _________ to compute.
► O (q) pg#48
► O (1)
► O (n2)
► O (n3)
98. ._______________ is a graphical representation of an algorithm
► notation
► notation
► Flowchart
► Asymptotic notation
►O(logn)
►O(n) pg#37
►O(nlogn)
►O(2n)
102. Consider the following Huffman Tree
►10 00 010
►011 00 010
►10 00 110
►11 10 110
103. .A greedy algorithm does not work in phases.
►True
►False pg#97
104. Can an adjacency matrix for a directed graph ever not be square in shape?
►Yes
►No pg#116
105. 44.One of the clever aspects of heaps is that they can be stored in arrays without using
any____________.
►Pointers pg#40
►constants
►variables
►functions
106. .Merge sort requires extra array storage,
AL-JUNAID TECH INSTITUTE
►True Page 54
►False
107. .Non-optimal or greedy algorithm for money change takes____________
►O(k) Pg #99
►O(kN)
►O(2k)
►O(N)
108. The Huffman codes provide a method of encoding data inefficiently when coded
using ASCII standard.
►True
►False Pg# 99
109. Using ASCII standard the string abacdaacac will be encoded with __________ bits.
►80 pg# 99
►160
►320
►100
110. Using ASCII standard the string abacdaacac will be encoded with 160 bits.
►True
►False (Pg# 99)
111. Using ASCII standard the string abacdaacac will be encoded with 320 bits.
►True
►False (Pg# 99)
112. .Using ASCII standard the string abacdaacac will be encoded with 100 bits.
►True
►False (Pg# 99)
113. Using ASCII standard the string abacdaacac will be encoded with 32 bytes
►True
►False (Pg# 99) 8bytes
114. The greedy part of the Huffman encoding algorithm is to first find two nodes with
smallest frequency.
►True
►False (Pg# 100)
AL-JUNAID TECH INSTITUTE
116. .Huffman algorithm uses a greedy approach to generate an antefix code T that
minimizes the expected length B (T) of the encoded string.
►True
►False (Pg# 102)
117. Depth first search is shortest path algorithm that works on un-weighted graphs.
►True
►False (Pg# 159)
►k
► dijk (Pg# 164)
►True
►Flase
120. .The term coloring came from the original application which was in map drawing.
►Apart from
►Far from
►Near to
►Adjacent to (Pg# 176)
122. . Fixed-length codes may not be efficient from the perspective of _______the total
quantity of data.
►Minimizing Pg# 99
►Averaging
►Maximizing
►Summing
123. In greedy algorithm, at each phase, you take the________ you can get right now,
without regard for future consequences.
AL-JUNAID TECH INSTITUTE
►Worst
►Minimum
►Good
124. The difference between Prim s algorithm and Dijkstra s algorithm is that Dijkstra s
algorithm uses a same key.
►True
►False Page# 156
125. If a problem is in NP-complete, it must also be in NP.
►2
►n
►2^n Page# 92
►3^n
127. .Using ASCII code, each character is represented by a fixed-length code word of
________ bits per character.
►4
►6
►8 pg # 99
►10
128. .In Knapsack Problem, the thief’s goal is to put items in the bag such that the ______
of the items does not exceed the limit of the bag.
►Weight
►Length
►Balance
129. The knapsack problem does not belong to the domain of optimization problems.
AL-JUNAID TECH INSTITUTE
►True
►False Page# 91
130. .In Huffman encoding, for a given message string, the frequency of occurrence
(relative probability) of each character in the message is determined last.
►True
131. Fixed-length codes are known for easy break up of a string into its individual
characters.
►True Page# 99
►False
132. In ______ Knapsack Problem, limitation is that an item can either be put in the bag or
not-fractional items are not allowed.
►0
►1
►0/1 Page# 91
►Fractional
133. In Knapsack Problem, value and weight both are to be under consideration.
►False
134. Time complexity of DP based algorithm for computing the minimum cost of chain
matrix Multiplication is ________ .
►log n
►n
►n2
135. In DP based solution of knapsack problem, to compute entries of V we will imply a/an
_______ approach.
►Subjective
►Brute force
AL-JUNAID TECH INSTITUTE
►Combination
►True Page# 97
►False
137. In Huffman encoding, frequency of each character can be determined by parsing the
message and __________ how many times each character (or symbol) appears.
►Printing
►Incrementing
►Deleting
►True Page# 97
►False
►Reading
►Encoding Page# 99
►Decoding
►Printing
140. In _______ based solution of knapsack problem, we consider 2 cases, Leave object
Or Take object.
►Brute force
141. Those problems in which Greedy finds good, but not always best is called a
greedy________.
►Algorithm
►Solution
►Heuristic Page# 97
►Result
AL-JUNAID TECH INSTITUTE
142. In brute force based solution of knapsack problem, we consider 2 cases, Leave object
Or Take object.
►TRUE
►FALSE Page# 97
►Minimization
►Averaging
►Optimization Page# 97
►Maximization
144. Using ASCII standard the string abacdaacac will be encoded with 10 bytes.
►True Page #101
►False
145. In _______ algorithm, you hope that by choosing a local optimum at each step, you
will end up at a global optimum.
►Simple
►Non Greedy
►Greedy Page# 97
►Brute force
146. Huffman algorithm uses a greedy approach to generate an prefix code T that
minimizes the expected length B (T) of the encoded string.
►True Page# 97
►False
►False
149. If the string “lmncde” is coded with ASCII code, the message length would be
_______ bits.
►24
AL-JUNAID TECH INSTITUTE
►36
►60
150. There are _________ nested loops in DP based algorithm for computing the minimum
cost of chain matrix multiplication.
►2
►3 Page# 90
►4
151. .A number of lectures are to be given in a single lecture hall. Optimum scheduling for
this is an example of Activity selection.
►False
152. The activity scheduling is a simple scheduling problem for which the greedy
algorithm approach provides a/an ________solution.
►Simple
►Sub optimal
►Non optimal
153. The string |xyz|, if coded with ASCII code, the message length would be 24 bits.
►False
154. An application problem is one in which you want to find, not just a solution, but the
____ solution.
►Simple
►Best
155. Suppose that a graph G = (V,E) is implemented using adjacency lists. What is the
complexity of a breadth-first traversal of G?
►O(|V |^2)
AL-JUNAID TECH INSTITUTE
►O(|V | |E|)
►O(|V |^2|E|)
►Breadth first search is shortest path algorithm that works on un-weighted graphs Page
#153
►Depth first search is shortest path algorithm that works on un-weighted graphs.
158. If you find yourself in maze the better traversal approach will be :
►BFS google
►Level order
►DFS
► (u, v) where u and v are not ancestor or descendent of one another Page# 129
162. Kruskal's algorithm (choose best non-cycle edge) is better than Prim's (choose best
tree edge) when the graph has relatively few edges.
►True google
►False
163. What algorithm technique is used in the implementation of Kruskal solution for the
MST?
►Divide-and-Conquer Technique
164. What is the time complexity to extract a vertex from the priority queue in Prim’s
algorithm?
►O (log E)
► (V)
► (V+E)
165. The relationship between number of back edges and number of cycles in DFS is,
166. You have an adjacency list for G, what is the time complexity to compute Graph
transpose G^T.?
► (V + E) Page# 138
AL-JUNAID TECH INSTITUTE
► (V E)
► (V)
► (V^2)
167. There is relationship between number of back edges and number of cycles in DFS
►There is no relationship between back edges and number of cycles. Page# 131
►A digraph is strongly connected if for every pair of vertices u, v e V, u can reach v and vice
versa. Page# 135
►A digraph is strongly connected if for at least one pair of vertex u, v e V, u can reach v and vice
versa.
►A digraph is strongly connected if at least one third pair of vertices u, v e V, u can reach v and
vice versa.
169. In in-place sorting algorithm is one that uses arrays for storage :
►An additional array
►O(n^2)
►O(nlogn) Page# 46
►O(n+k)
AL-JUNAID TECH INSTITUTE
►O(n^3)
►Large
►Medium
►Not known
►Small
173. Quick sort is based on divide and conquer paradigm; we divide the problem on base of
pivot element and:
► Has both greedy and dynamic approach to compute single source shortest paths to all other
vertices.
175. Which may be stable sort:
►Bubble sort
►Insertion sort
►Both of above page# 54
►Selection sort
176. In the analysis of Selection algorithm, we eliminate a constant fraction of the array with each
phase; we get the convergent _______________ series in the analysis,
►linear
►arithmetic
►geometric page #37
►exponent
177. How much time merge sort takes for an array of numbers?
►T(n^2)
►T(n) Page# 40
►T( log n)
►T(n log n)
► False
180. Consider the following adjacency list:
182. . After partitioning array in Quick sort, pivot is placed in a position such that
► Values smaller than pivot are on left and larger than pivot are on right
Page# 48
► Values larger than pivot are on left and smaller than pivot are on right
► Pivot is the first element of array
► Pivot is the last element of array
183. . Merge sort is stable sort, but not an in-place algorithm
► notation
► notation
► Flowchart
► Asymptotic notation
188. Which of the following is calculated with big o notation?
►Lower bounds
►Upper bounds (Page# 25)
►Both upper and lower bound
►Medium bounds
189. Merge sort makes two recursive calls. Which statement is true after these
recursive calls finish, but before the merge step?
►The array elements form a heap
►Elements in each half of the array are sorted amongst themselves
►Elements in the first half of the array are less than or equal to elements in the second half of
the array
►None of the above
190. Non-optimal or greedy algorithm for money change takes____________
►True
►False (Page #99)
194. using ASCII standard the string abacdaacac will be encoded with 32 bytes
►True
►False (Page #99)
195. The greedy part of the Huffman encoding algorithm is to first find two nodes
with smallest frequency.
►True
►False (Page# 100)
197. Huffman algorithm uses a greedy approach to generate an antefix code T that
minimizes the expected length B (T) of the encoded string.
►True
►False (Page #102)
198. Depth first search is shortest path algorithm that works on un-weighted graphs.
►True
►False (Page# 153)
199. 12Dijkstras single source shortest path algorithm works if all edges weights
are non negative and there are no negative cost cycles.
►True (Page#159)
►False
200. Dijkestra s single source shortest path algorithm works if all edges weights are
negative and there are no negative cost cycles.
►True
►False (Page #159)
201. Floyd-Warshall algorithm is a dynamic programming algorithm; the genius of
the algorithm is in the clever recursive formulation of the shortest path problem.
►k
► dijk (Page# 164)
►True
►False
203. the term coloring came from the original application which was in map
drawing.
►Apart from
►Far from
►Near to
►Adjacent to (Page# 176)
205. Fixed-length codes may not be efficient from the perspective of
_______the total quantity of data.
►Averaging
►Maximizing
►Summing
206. In greedy algorithm, at each phase, you take the________ you can get right
now, without regard for future consequences.
►Worst
►Minimum
►Good
207. The difference between Prim s algorithm and Dijkstra s algorithm is that
Dijkstra s algorithm uses a same key.
►True
►False ( Page# 156)
208. If a problem is in NP-complete, it must also be in NP.
AL-JUNAID TECH INSTITUTE
► True (Page #178)
► False
209. If there are n items, there are _______ possible combinations of the items.
►2
►n
►2^n (Page# 92)
►3^n
210. Using ASCII code, each character is represented by a fixed-length code word
of ________ bits per character.
►4
►6
►8 (Page #99)
►10
211. In Knapsack Problem, the thief’s goal is to put items in the bag such that the
______ of the items does not exceed the limit of the bag.
►Value (Page# 91)
►Weight
►Length
►Balance
212. The knapsack problem does not belong to the domain of optimization
problems.
►True
►False (Page# 91)
213. In Huffman encoding, for a given message string, the frequency of occurrence
(relative probability) of each character in the message is determined last.
►True
►False (Page #100)
214. Fixed-length codes are known for easy break up of a string into its individual
characters.
►False
215. In ______ Knapsack Problem, limitation is that an item can either be put in the
bag or not-fractional items are not allowed.
►0
►1
►0/1 (Page# 91)
►Fractional
216. The term “coloring” came from the original application which was in
architectural design.
► True
► False (Page# 173)
217. In Knapsack Problem, value and weight both are to be under consideration.
►True (page# 91)
AL-JUNAID TECH INSTITUTE
►False
218. Time complexity of DP based algorithm for computing the minimum cost of
chain matrix Multiplication is ________ .
►log n
►n
►n2
►n3 (Page# 90)
219. In DP based solution of knapsack problem, to compute entries of V we will
imply a/an _______ approach.
►Subjective
►Inductive (Page# 93)
►Brute force
►Combination
220. A greedy algorithm sometimes works well for optimization problems.
►True (Page# 97)
►False
221. In Huffman encoding, frequency of each character can be determined by
parsing the message and __________ how many times each character (or symbol)
appears.
►Printing
►Incrementing
►Counting (Page# 100)
►Deleting
222. .Greedy algorithm can do very poorly for some problems.
►True (Page# 97)
►False
223. The Huffman codes provide a method of _________ data efficiently.
►Reading
►Encoding (Page# 99)
►Decoding
►Printing
224. In _______ based solution of knapsack problem, we consider 2 cases, Leave
object Or Take object.
►Brute force
►Dynamic programming (Page #93)
225. Those problems in which Greedy finds good, but not always best is called a
greedy________.
►Algorithm
►Solution
►Heuristic (Page# 97)
►Result
AL-JUNAID TECH INSTITUTE
226. In brute force based solution of knapsack problem, we consider 2 cases, Leave
object Or Take object.
►TRUE
►FALSE (Page# 97)
227. ________ problem, we want to find the best solution.
►Minimization
►Averaging
►Optimization (Page#97)
►Maximization
228. Using ASCII standard the string abacdaacac will be encoded with 10 bytes.
►True (Page# 101)
►False
229. In _______ algorithm, you hope that by choosing a local optimum at each step,
you will end up at a global optimum.
►Simple
►Non Greedy
►Greedy (Page# 97)
►Brute force
230. Huffman algorithm uses a greedy approach to generate an prefix code T that
minimizes the expected length B (T) of the encoded string.
►True (Page #102)
►False
231. How many elements do we eliminate in each time for the Analysis of Selection
algorithm?
►n / 2 elements (Page #37)
► (n / 2) + n elements
►n / 4 elements
►2 n elements
►16
►10
►32
►31
240. For the heap sort, access to nodes involves simple _______________
operations.
►T(n)
►T(1 / 1 + n)
►T(n / 2)
►T((n / 2) + n) (Page #37)
246. For the heap sort we store the tree nodes in
►level-order traversal (Page #40)
►in-order traversal
►pre-order traversal
►post-order traversal
247. The reason for introducing Sieve Technique algorithm is that it illustrates a
very important special case of,
►divide-and-conquer (Page# 34)
►decrease and conquer
►greedy nature
►2-dimension Maxima
248. Theta asymptotic notation for T (n) :
►Merger
►Insertion
► Both above (Page #54)
►None of the above
255. . An in place sorting algorithm is one that uses ___ arrays for storage
►Two dimensional arrays
►More than one array
►No Additional Array (Page #54)
►None of the above
256. Continuing sort has time complexity of ?
►O(n
►O(n+k)
►O(nlogn)
►O(k)
257. single item from a larger set of _____________
►n items (Page# 34)
►phases
►pointers
►v constant
258. For the Sieve Technique we take time
if (n=1)
return 1
AL-JUNAID TECH INSTITUTE
else
return (n * Factorial(n-1))
► T(n) = T(n-1) +1
► T(n) = nT(n-1) +1
► T(n)= T(n-1) +n
► T(n)=T(n(n-1)) +1
261. Due to left complete nature of binary tree, the heap can be stored in
► Arrays (Page #40)
► Structures
► Link List
►Stack
262. What type of instructions Random Access Machine (RAM) can execute?
►Algebraic and logic
►Geometric and arithmetic
►Arithmetic and logic (Page# 10)
►Parallel and recursive
263. What is the total time to heapify?
► Ο(log n) (Page 43)
► Ο(n log n)
► Ο(n2 log n)
► Ο(log2 n)
264. word Algorithm comes from the name of the muslim author ____________
►Abu Ja’far Mohammad ibn Musa al-Khowarizmi.
265. Al-Khwarizmi’s work was written in a book titled _______________
►al Kitab al-mukhatasar fi hisab al-jabr wa’l-muqabalah
266. Random access machine or RAM is a/an
► Machine build by Al-Khwarizmi
► Mechanical machine
► Electronics machine
► Mathematical model (Page# 10)
267. A RAM is an idealized machine with ______________ random-access
memory.
► 256MB
► 512MB
► an infinitely large (Page #10)
► 100GB
268. What will be the total number of max comparisons if we run brute-force
maxima algorithm with n elements?
2
► n
n
►n
2
►n (Page# 14)
8
AL-JUNAID TECH INSTITUTE
►n
269. Consider the following code:
For(j=1; j<n;j++)
For(k=1; k<15;k++)
Do_something_constant();
► O(n)
► O(n3)
► O(n2 log n)
► O(n2)
270. Is it possible to sort without making comparisons?
► Yes (Page# 57)
► No
271. When we call heapify then at each level the comparison performed takes time
► It will take Θ (1) (Page# 43)
► Time will vary according to the nature of input data
► It can not be predicted
► It will take Θ (log n)
272. In Quick sort, we don’t have the control over the sizes of recursive calls
► True (Page# 40)
► False
► Less information to decide
► Either true or false
273. For Chain Matrix Multiplication we cannot use divide and conquer approach
because,
► We do not know the optimum k (Page# 86)
► We use divide and conquer for sorting only
► We can easily perform it in linear time
► Size of data is not given
274. The Knapsack problem belongs to the domain of _______________ problems.
► Optimization (Page# 91)
► NP Complete
► Linear Solution
► Sorting
275. Suppose we have three items as shown in the following table, and suppose the
capacity of the knapsack is 50 i.e. W = 50.
AL-JUNAID TECH INSTITUTE
Item Value Weight
1 60 10
2 100 20
3 120 30
► Items 1 and 2
► Items 1 and 3
► Items 2 and 3
► None of these
276. who invented the quick sort
►C.A.R. Hoare
277. main elements to a divide-and-conquer
►Divide, conquer, combine (Page# 27)
278. Mergesort is a stable algorithm but not an in-place algorithm.
a. n
b. n+1
a. Verticals
• Weights
a. Updating
b. Amendment
a. Weighted
b. Directed
313. The relationship between number of back edges and Number of cycles in DFS is,
314. From given algorithms which one considered as best for finding the shortest-path:
DFS
Bellman-Ford algorithm
BFS
315. Overall time for Kruskal
algorithm is
a. Θ(log E)
c. Θ(E log E)
d. Θ(V log E)
A digraph is strongly connected if for at least one pair of vertex u, v e V, u can reach v and
vice versa.
A digraph is strongly connected if at least one third pair of vertices u, v e V, u can reach v and
vice versa.
AL-JUNAID TECH INSTITUTE
318. Floyd-Warshall Algorithm is based on ______________
• Complexity theory
b. Increasing
320. . ________ is commonly the running time of Dijkstra's Algorithm using the
binary heap method.
• Θ (V log )
• Θ (log E)
• Θ (Blog V)
321. Which technique is used in the implementation of Kruskal solution for the MST?
d. The algorithm combines more than one of the above techniques i.e. Divide-and-
322. A fully connected undirected graph of 5 nodes will have _______ edges.
4
AL-JUNAID TECH INSTITUTE
5
10 n(n-1)/2
d. 15
b. Dynamic programming
d. Exponential
324. We say that two vertices u and v are mutually ______if u can reach v and vice
versa.
a. Crossed
b. Forward
d. Not Reachable
AL-JUNAID TECH INSTITUTE
325. In Dijkstra's algorithm, initially the estimated value from source vertex to any
vertex v is:
a. Zero (0)
b. One (1)
• Undirected Graph
No MST
328. In ______ algorithm(s), at any time, the subset of edges A forms a single tree.
a. Kruskals
d. BFS
d. node stamps
a. Links
• nodes
• Loops
331. Keeping in mind the shortest path, if given scenarios occur in computer networks
like the internet where data packets have to be routed. The vertices are _______. Edges
are
• Internet, routers
• Routers, internet
AL-JUNAID TECH INSTITUTE
332. In computing the strongly connected components of a digraph. vertices of the
digraph
333. In undirected graph, by convention all the edges are called _______edges.
a. Forward
c. Cross
a. 1 cycle
c. DFS
d. BFS
335. . In Prim's algorithm, we start with the ______vertex r, it can be any vertex.
• Pivot
• Leaf
• negative
a. addition
b. division
• Kruskal's algorithm is used to find minimum spanning tree of a graph, time complexity
of this algorithm is 0(EV)
• Both I and II
• Kruskal’s algorithm (choose best non-cycle edge) is better than Prim's (choose
best Tree edge) when the graph has relatively few edges.
See option B of Sr 46
338. . The time complexity to compute Graph transposes G^T is (V+E), if you have __
for G.
• Array list
• complete list
• stack
AL-JUNAID TECH INSTITUTE
339. . In Prim's algorithm, If there is no edge from u to a vertex in S. we set the
key value to_____
• 0
• 1
• -1
d. ∞ page 151
340. . What is the time complexity to extract a vertex from the priority queue in
Prim's algorithm?
• O(log E)
• O(V)
• O(V+E)
• in breadth-First Search
• in Queue's
342. The ________ given by DFS allow us to determine whether the graph contains
any
cycles.
a. Order
c. BFS traversing
d. Topological sort
AL-JUNAID TECH INSTITUTE
343. . Dijkstra's algorithm works on a weighted directed graph G(V, E) in which all
weights
a. Vertices
• nodes
• links
344. . By breaking any edge on a cycle created in free tree, the free_____ is restored.
a. Edge
c. Cycle
d. Vertex
c. Flow of networking
• O(N)
• O(N^3)
• O(N^2)
d. O(log N) google
a. Bellman-Ford page 16
53) Dijkstra's
54) Prim's
348. In Timestamped DFS-cycles lemma, if edge (u, v) is a tree, forward or cross edge,
then a. f[u] < f[v]
350. Kruskal algorithm (choose best non cycle edge) is better than Prims (choose
best tree edge) when the _______has relatively few______
AL-JUNAID TECH INSTITUTE
a. tree, edges
• tree, branches
• graph, branches
351. Finding the faster result of the shortest path from u to v for every pair of
vertices and we use ____
b. Back
b. Incomplete
c. Not graphs
d. Transportation
b. Has both greedy and Dynamic approach to find all shortest paths
c. Has greedy approach to compute single source shortest paths to all other
e. Has both greedy and dynamic approach to compute single source shortest paths to all
other vertices
a. Brute-force technique
58) Prim's
• unweighted graphs
AL-JUNAID TECH INSTITUTE
• undirected and unweighted graphs
357. . Which of the following is used in the data structure for implementing
Dijkstra's Algorithm?
a. Max heap
b. Stack's
c. Circular queue
• Vertices
• Cycles
• Paths
• Equal to 1
• Greater than 0
• Greater than 1
AL-JUNAID TECH INSTITUTE
360. Dijkstra's algorithm is a simple________ algorithm for computing the single-
source
c. Bellman-Ford
e. Brute-Force
a. Nothing
c. a line
d. a graph
362. There exists a unique path between any _______ vertices of a free tree.
a. One
• Three
• Four
a. Generic traversal
364. You have an adjacency list for G, what is the time complexity to compute
Graph transpose G^T?
• V.E
• V
• E
365. In the shortest-paths problem, we are given a weighted of ______G =(V, E).
366. Equivalence relation partitions the vertices into _______ classes of mutually
reachable
a. Variance
c. Non equivalence
d. Non classes
AL-JUNAID TECH INSTITUTE
367. Overall Running time of Prim's algorithm is _________.
a. Θ(ElogE)
b. Θ(ElogV)
368. For ________ graphs, there is no distinction between forward and back edges.
a. large
b. directed
369. For ________ graphs, there is no distinction between forward and back edges.
• directed
• small
• large
370. As the Kruskal's algorithm runs, the edges in viable set A induce a ________ on
the
vertices.
a. Set
b. Graph
c. Tree
371. In strong components algorithm, the form of graph is used in which all the
_______ of
d. Trees
372. In computing the ________ components of a digraph, vertices of the digraph are
digraph.
a. DFS google
b. BFS
d. MST
AL-JUNAID TECH INSTITUTE
374. In Prim's algorithm, if the color of a vertex is _______ then it is in S otherwise
not.
a. White
b. Gray
376. Once you enter a strong component, every vertex in the component is
________.
a. not reachable
d. removed
377. In Kruskal’s algorithm, the next edge is added to viable set A, if its adding
does not induce a/an __________.
a. Vertex
b. Edge
a. Tree
c. Linked list
d. Stack
379. In Bellman-Ford Algorithm, relaxation applies to every edge of the graph and
repeat this ______ time.
a. E – 1
b. E + 1
c. V + 1
d. V – 1 page 159
380. A topological sort of a DAG is a ________ ordering of the vertices of the DAG
such
that for each edge (u, v), u appears before v in the ordering.
b. Parallel
c. Sequence
d. Non-linear
AL-JUNAID TECH INSTITUTE
381. Adding any edge to a free tree creates a unique ______
a. Vertex
b. Edge
d. Strong component
383. In Kruskal's algorithm, the next _______is not added to viable set A, if its adding
385. . In strong components algorithm, first of all DFS is run for getting _______
times of
vertices.
AL-JUNAID TECH INSTITUTE
a. Start page 138
b. Finish
c. Both start & finish
d. Middle
386. . The tricky part of _______ algorithm(s) is/are, how to detect whether the addition
of an
387. . _________ components are not affected by reversal of all edges in terms of
vertices
reachability.
a. Stack
c. Array
d. List
a. straight
b. cyclic
a. vertices, nodes
b. edges, vertices
c. nodes, vertices
391. If you find yourself in maze the better traversal approach will be:
c. Level order
d. DFS
392. Forward
edge is :
c. (u, v) where u and v are not ancestor or descendent of one another page 129
a. Θ(V + E)
b. Θ(E + E)
b. Every Vertices
396. If a subset of edges A is visible for building MST, it cannot contain a/an____
a. Vertex
b. Edge
a. f[u] <f[v]
AL-JUNAID TECH INSTITUTE
b. f[u] > f[v]
399. . The key[u] is the weight of the ________ going from u to any vertex in S.
b. edge
c. lighter edge
d. heavier edge
c. E + 1
d. E-1
401. According to parenthesis lemma, vertex u is a descendent of v vertex it and only if;
c. Unrelated
d. Disjoint
AL-JUNAID INSTITUTE GROUP
402. Edge weights can be interpreted as distance ________.
a. in breadth-First Search
b. in Queue's
d. in depth-First Search
403. __________ algorithm allows negative weights edges and no negative cost
cycles.
a. Brute-force technique
c. Dijkstra’s
d. Print
404. In Huffman encoding, the characters with smallest probabilities are placed at
the------------depth of the tree.
a. Minimum
b. Average
• Root
• 1
• 2 page 116
a. 4
406. Each time we traverse graph by Breadth-first search algorithm, we count the
distance from----------.
AL-JUNAID INSTITUTE GROUP
a. Starting node
a. Simple
b. Sub-optimal
c. Non optimal
409. The ------------- is a problem for which the greedy algorithm approach provides
an optimal solution.
• Dynamic programming
• Knapsack problem
• NP complete problem
410. Which of the following ways can be used to represent a graph?
a. Adjacency list
AL-JUNAID INSTITUTE GROUP
b. Incidence matrix
• No way to represent
411.
Queue Data Structure work on ------------- principles.
4
• FIFO(first in first out) cs301
• queue , stack
b. Binary , linear
413. Identify a TRUE statement about Knapsack.
• Greedygoogle
• Brute force
• Dynamic programming
416. The running time of brute-force algorithm to solve Knapsack problem is------
• O(h1)
• O(n3)
• O (n!)
• O(2^n) pg#92
417. If a matrix has three rows and two columns, the dimension of matrix will be:
• 3x2 Conceptual
• 2x3
• 3x3
• 2x2
AL-JUNAID INSTITUTE GROUP
418. The Probability in Huffman encoding is the number of occurrences of a
character divided by the total-
c. Numbers
d. Frequencies
e. Strings
f. Characters pg#100
• -1
• 0 pg#93
• 1
• 2
420. The Knapsack Problem belongs to the domain of-----------problem.
g. Optimization pg#91
h. Sorting
i. Linear solution
j. Searching
k. Simple
l. Good
m. Best pg#97
AL-JUNAID INSTITUTE GROUP
• Worst
• Postfix
• Infix
423. Which of the following algorithms solves the Fractional Knapsack Problem
more effectively?
• Dynamic programming
• Backtracking
424. One of the limitation in 0/1 Knapsack is that an item can either be----------in the
bag or not.
Use
• Put page 91
• Move
Store
n. Is always ignored
p. Should be maximized
Balances
Maximizes
Keeps constant