CS502 MidTerm MCQs by Talha Sajid
CS502 MidTerm MCQs by Talha Sajid
3. 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
d) Fractional
5. In Bucket sort, if there are duplicates then each bin can be replaced by a __________.
a) Hash table
b) Heap
c) Stack
d) Linked list
7. The average case running time of quick sort algorithm is theta _________.
a) n x n log(n)
b) Log(n)
c) nlog(n)
d) (n)
b) fast
c) memory
d) slow
12. In max heap (for Heap Sort algorithm), when every time maximum element is removed
from top we replace it with _____ leaf in the tree.
a) second last
b) Last
c) First
d) Any
14. 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.
a) 3x2
b) 2x3
c) 2x2
d) 3x3
18. In average-case time analysis of Quick sort algorithm, the most balanced case for
partition is when we divide the list of elements into _.
a) Equal no. of pieces as of input elements
b) Single piece exactly
b) RAM
c) Computer
d) Compiler
24. When a recursive algorithm revisits the same problem over and over
again, we say that the optimization problem has ________ sub-problems.
a) Overlapping
b) Over costing
c) Optimized
d) Three
25. In order to say anything meaningful about our algorithms, it will be important for us to
settle on a ______.
a) Java Program
b) C++ Program
c) Pseudo program
d) Mathematical model of computation
27. Quick sort does not require any additional array for storage except for
recursive function calls is called __________.
a) In-Place
b) Stable
c) Not In-Place
d) Unsorted
29. What is the worst-case time of a quick sort which happens rarely?
a) O(log n)
b) O(n log n)
c) O(n2)
d) O(n)
c) (n-1)/2
d) (n+1)/2
34. _________ is one of the few problems, where provable lower bounds exist on how fast
we can sort.
a) Sorting
b) Graphing
c) Searching
d) Both Searching & Sorting
a) 37. What time does Merge Sort algorithm take in order to sort an
b) array of 'n' numbers?
a) (n)
b) (log n)
c) (n^2)
d) (n log n)
c) ϴ (n + 100)
42. . In merge sort algorithm, to merge two lists of size n/2 to a list of size n, takes
_______ time.
a) Theta (n)
b) Theta log(n)
c) Theta log2(n)
d) Theta n log(n)
43. For average-case time analysis of quick sort algorithm, pivot selection
is on average basis from _________.
a) All possible random values
b) Pivot is input separately
c) half of the input values
d) Values greater than 5
46. In chain matrix multiplication, table is filled ______ to find the multiplication of matrix.
a) row wise
b) column wise
c) diagonally
d) bottom-to-up
47. . In plane sweep approach, a vertical line is swept across the 2dplane and structure is
used for holding the maximal points lying to the left of the sweep line.
a) Array
b) Queue
c) Stack
d) Tree
48. The only way to convert a string of i characters into the empty string is
with i deletions, represented as _____________.
a) E(0.j) =j
b) E(i.j) = 1
c) E(0.i) = j
d) E (i.0)=I
49. . When a heapify procedure is applied to the root node to restore the heap, then at each
level, the comparison performed takes time:
50. If there are Θ (n²)entries in edit distance matrix then the total running time is:
a) θ (n)
b) θ (1)
c) θ (n2 )
d) θ (n logn)
51. _____ time is the maximum running time over all legal inputs.
a) Worst-case
b) Average-case
c) Best-case
d) Good-case
52. In average –case time analysis of quick sort algorithm , the mostbalanced case for
partion is when we divide the list of elements into _.
a) Equal no. of pieces as of input elements
b) Single piece exactly
c) Two nearly equal pieces
d) Three nearly equal pieces
55. For average-case time analysis of Quick sort algorithm, Pivot selection is on average
basis from ______
a) half of the input values
b) all possible random values
c) Pivot is input separately
d) values greater than 5
56. Fibonacci Sequence was named on _______, a famous mathematician in 12th Century.
a) Fred Brooks
b) Grady Booch
c) Leonardo Pisano
d) Edgar F. Codd
d) Less than 5
59. Recurrence can be described in terms of a tree.
a) Yes
b) No
60. For comparison-based sorting algorithms, it is possible to sort more efficiently than
Omega n log(n) time.
a) Always
b) Sometimes not
c) NOT
d) Sometimes
61. Time complexity of Dynamic Programming based algorithm for computing the
minimum cost of Chain Matrix Multiplication is ______
a) Log n
b) n
c) n^2 (n square)
d) n^3 (n cube)
64. 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
d) Fractional
66. In Selection algorithm, we assume pivot selection takes theta __________ running time.
a) n
b) n2
c) n3
d) log (n)
67. Chain matrix multiplication problem can be solved through ______ strategy.
a) Dynamic programming
b) Greedy
c) Divide and conquer
d) Sorting
68. In Heap Sort algorithm (using max heap), when every time maximum element is
removed from top ___________.
a) We call merge Sort Algorithm
b) it becomes Order n2 Algorithm
c) Divide and Conquer strategy helps us
69. Merge sort have running time....running time of Heap sort. Not found exactly
a) Greater than
b) Less than
c) Equal to
d) Different than
70. _________ is a method of solving a problem in which we check all possible solutions to
the problem to find the solution we need.
a) Plane-Sweep Algorithm
b) Sorting Algorithm
c) Brute-Force Algorithm Google
d) Greedy approach
71. Median is not useful measure of central tendency of given input set especially when the
distribution of values is highly skewed.
a) True
b) False
72. The worst case running time of quick sort algorithm ____________.
a) Is quadratic
b) Is linear
c) Cannot be quadratic
d) ls always Exponential
73. We do not need to mathematically prove that for comparisonbased sorting algorithms
always takes Omega nlog (n) time.
a) True
b) False
74. In max heap (for Heap Sort algorithm), when every time maximum element is removed
from top we replace it with ___________ leaf in the tree.
a) Last
b) First
c) Any
d) Second last
75. The Omega-notation allows us to state only the asymptotic ______ bounds.
a) Middle
b) Lower
c) Upper
d) Both lower & upper
78. If Matrix-A has dimensions “3×2” and Matrix-B has dimensions “2×3”, then
multiplication of Matrix-A and Matrix-B will result a new MatrixC having dimensions.
a) 3×2
b) 2×3
c) 2×2
d) 3×3
79. Radix sort performs sorting the numbers _______ digit (s) at a time.
a) One
b) Two
c) Three
d) All
80. In Sorting the key value or attribute __________ from an ordered domain.
a) Must be
b) Not always
c) May be
d) Occasionally
82. Result of asymptotical analysis of n(n -3) and 4n*n is that _______
a) n(n-1) is asymptotically Less
b) n(n-1) is asymptotically Greater
c) Both are asymptotically Not equivalent
d) Both are asymptotically Equivalent
83. Consider three matrices X,Y,Z of dimensions 1x2, 2x3,3x4 respectively. The number of
multiplications of (XY) Z is:
a) 18
b) 32
c) 24
d) 30
84. Floor and ceiling are ______ to calculate while analyzing algorithms
a) Very easy
b) 3rd Option is missing
c) Usually considered difficult
d) 4th Option is missing
88. In max-heap, largest element is stored at root node. Where is the smallest element
stored?
a) Right Node
b) Leaf Node
c) Middle Node
d) Left Node
a) Commutative
b) Associative
c) Neither commutative nor associative
d) Commutative but not associative
95. In Knapsack problem, the goal is to put items in the Knapsack such that
the value of the items is __________ subject to weight limit of knapsack.
a) Minimized
b) Decreased
c) Maximized
d) None of the given options
96. An in-place sorting algorithm is one that ________ uses additional array for storage.
a) Always
b) Permanently
c) Does not
d) Sometime
100. In order to say anything meaningful about our algorithms, it will be important for us
to settle on a ______.
a) Java Program
b) C++ Program
c) Pseudo program
d) Mathematically model of computation
101. What time does Merge Sort algorithm take in order to sort an array of ‘n’ numbers?
a) Θ (n)
b) Θ (log n)
c) Θ (n^2)
d) Θ(n log n)
106. Time will vary according to the nature of input data. _____ time is the maximum
running time over all legal inputs.
a) Worst-case
b) Average-case
c) Best-case
d) Good-case
a) A.(n2)
b) (n)
c) log(n)
d) n log(n)
110. Merge sort have running time….running time of Heap sort. Not found exactly
a) Greater than
b) Less than
c) Equal to
d) Different than
113. Consider three matrices X,Y,Z of dimensions 1×2, 2×3,3×4 respectively. The number
of multiplications of (XY) Z is:
a) 18
b) 32
c) 24
d) 30
117. An in-place sorting algorithm is one that ___________ use(s) additional array for
storage.
a) Always
b) Permanently
c) Does not
d) Sometime
118. In Fibonacci Sequence, each term is calculated by_______ previous ______ terms.
a) Subtracting, Two
b) Adding, Three
c) Adding, Two
d) Multiplying, Two
120. ___________ provides us more accurate result, when input values are not closer with
each other.
a) Mode
b) Mean
c) Average
d) Median
122. If the time complexity of an algorithm is given by O (1), then its time complexity would
be
a) Polynomial
b) Exponential
c) Constant
d) Average
125. _______ provides us more accurate result when input values are not closer with each
other
a) Average
b) Median
c) Mode
d) Mean
c) Size
d) Growth rates
136. For solving Selection problem, we introduced Sieve technique due to _______
a) Using Decrease and Conquer strategy
b) Avoiding to sort all input data
c) Eliminating Rank of an element
d) Using Brute-force approach
138. In in-place sorting algorithm is one that uses arrays for storage.
a) No additional array
b) An additional array
c) Both of above may be true according to algorithm
d) More than 3 arrays of one dimension
142. For 2D Maxima problem. Plane Sweep algorithm first of all _________.
a) Sorts all points
b) Delete some points
c) Output the elements
d) Pushes all points on stack
145. To check whether a function grows faster or slower than the other function, we use
some asymptotic notations, which is ________.
a) Big-oh notation
b) Theta notation
c) Omega notation
d) All of the given
d) Array
151. In selection problem, the rank of an element will be its _____ position
a) First
b) final
c) Second last
d) Last
152. f(n) and g(n) are asymptotically equivalent. This means that they have essentially the
same ______.
a) Size
b) Results
c) Variables
d) Growth Rates
154. In asymptotical analysis of n'(5 2)-3, as n becomes large, the dominant (fastest growing)
term is some constant times
a) n_1
b) n
c) n+1
d) n*n p-23
156. To find maximal points in brute-force algorithm each point of the space is compared
against ______ of that space.
a) One other point
b) All other points Page 11
c) Few other points
d) Most of the other points
160. In quick sort algorithm, _________ decides nature of Binary Search Tree formed by
pivots.
a) Rank of the pivot
b) Middle element from input
c) Smallest element from input
d) Largest element from input
161. In the clique cover problem, for two vertices to be in the same group,
they must be ______ each other.
a) Apart from
b) Far from
c) Near to
d) Adjacent to
162. In in-place sorting algorithm is one that uses arrays for storage.
a) No additional array
b) An additional array
c) Both of above may be true according to algorithm
d) More than 3 arrays of one dimension
165. Asymptotic growth rate of the function is taken over ______ case running time.
a) Worst
b) Average
c) Best
d) Normal
167. In brute force algorithm, we measure running time T(n) based on ____.
a) Worst-case time and best-case time
b) Worst-case time and average-case time
c) Average-case time and best-case time
d) Best-case time and staring-case time
168. _________ is the process of avoiding unnecessary repetitions by writing down the
results of recursive calls and looking them up again if we need them later.
a) Loop
b) Function
c) Recursion
d) Memorization
170. Number of _______ of the pseudo code are counted to measure the running time.
a) Inputs
b) Outputs
c) Steps
d) Pages
171. In bin sort, each bin can be replaced by a ______________ in case of duplication.
a) Heap
b) Stack
c) Hash table
d) Linked list
172. In merge sort algorithm, we split the array ______ to find index q.
a) from end
b) from start
c) midway
d) both from start or end
173. Find the maximum value of the items which can carry using knapsack
Knapsack weight capacity = 50.
Item Weight Value
11070
22020
33080
470 200
a) 90
b) 280
c) 200
d) 100
176. The brute-force algorithm for 2D-Maxima runs in order O(__) time.
a) n
b) n(log n)
c) n*n
d) n3
178. If a matrix has three rows and two columns, then dimensions of matrix will be:
a) 3×2
b) 2×3
c) 3×3
d) 2×2
b) Row, Column
c) Finite, Infinite
d) Graph, Tree
182. In 2d-maximal problem, a point is said to be if it is not dominated by any other point
in that space.
a) Member
b) Minimal
c) Maximal
d) Joint
183. We can use the _______________ property to devise a recursive formulation of the edit
distance problem.
a) Small substructure
b) Algorithmic
c) Real
d) Optimal substructure
184. The problem with the brute-force algorithm is that is uses ________ in pruning out de
a) Worst-case time
b) No intelligence
c) Outside looping
d) Artificial intelligence
189. In 2d-maximal problem, a point is said to be if it is not dominated by any other point
in that space.
a) Member
b) Minimal
c) Maximal
d) Joint
a) Optimize sequence
b) Fibonacci sequence
c) Optimal sequence
d) Overlapping sequence
191. In chain matrix multiplication, table is filled _________ to find the multiplication of
matrix.
a) row wise
b) column wise
c) diagonally
d) bottom-to-up
194. Algorithms similar to those for the ______________ problem are used
in some speech recognition systems.
a) Counting
b) heap sort
c) Fibonacci
d) edit-distance
196. We can multiply two matrices A and B only when they are compatible
which means:
a) Number of rows and columns do not matter
b) Number of rows in A must be equal to number of rows in B
c) Number of columns in A must be equal to number of rows in B
d) Number of columns in A must be equal to number of columns in B
197. _______ overcomes the limitations of ________ by working as per positional notations
of numbers.
a) Bubble sort, Radix sort
b) Radix sort, Bubble sort,
c) Counting sort, Radix sort
d) Radix sort, Counting sort
Best of Luck
For Free help, more Mid/Final term Files and for Exam Preparation :You Can
Join: