0% found this document useful (0 votes)
28 views46 pages

CS502 Mid Term by JUANID

The document discusses algorithms and data structures. It provides examples of algorithms like merge sort and quick sort. It also discusses concepts like asymptotic analysis, divide and conquer strategy, and dynamic programming. Multiple choice questions with answers are given related to algorithms, their time complexities, and applications.

Uploaded by

Atif Mubashar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views46 pages

CS502 Mid Term by JUANID

The document discusses algorithms and data structures. It provides examples of algorithms like merge sort and quick sort. It also discusses concepts like asymptotic analysis, divide and conquer strategy, and dynamic programming. Multiple choice questions with answers are given related to algorithms, their time complexities, and applications.

Uploaded by

Atif Mubashar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

AL-JUNAID INSTITUTE OF GROUP

0304-1659294 0
AL-JUNAID INSTITUTE OF GROUP
1. The sequence of merge sort algorithm is:
a. Divide Combine-Conquer
b. Conquer-Divide-Combine
c. Divide-Conquer-Combine Page 27
d. Combine-Divide-Conquer
2. 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 Page 91
d. Fractional
3. In Selection algorithm, we assume pivot selection takes theta
_______ running time.
a. n Page - 36
b. n2
c. n3
d. log (n)
4. In Heap Sort algorithm (using max heap), when every time
maximum elements removed from top ________.
a. We call merge Sort Algorithm
b. it becomes Order n2 Algorithm
c. Divide and Conquer strategy helps us
d. We are left with a hole Page – 41
5. If matrix A of dimension p x q is multiply with matrix B of dimension
q x r, then each entry in resultant matrix takes _______ time.
a. O (q) Page - 84
b. O (1)
c. O (p x q)
d. O (q x r)
AL-JUNAID INSTITUTE OF GROUP
AL-JUNAID INSTITUTE OF GROUP
6. _________ 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
7. The worst case running time of Quick sort algorithm _____.
a. Cannot be quadratic
b. Is quadratic
c. ls always Exponential
d. Is linear
8. 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 Page -41
c. First
d. Any
9. Quick sort algorithm was developed by -
a. AlferdAho
b. Sedgewick
c. John Vincent Atanasoff
d. Tony Hoare – Google wikipedia
10. 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 http://www.calcul.com/show/calculator/matrix-multiplication
11. For comparison-based sorting algorithms, it is possible to sort
more efficiently than Omega n log(n) time.
a. Always
b. Not P-54
c. Sometimes
AL-JUNAID INSTITUTE OF GROUP
d. Sometimes not
12. Dynamic Programming approach is usually useful in solving
optimization problems.
a. True
b. False
13. In Sorting the key value or attribute_____ from an ordered domain.
a. Must be page 39
b. Not always
c. May be
d. Occasionally
14. 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 page 23 (4n*n= 4n2)
15. Floor and ceiling are ______ to calculate while analyzing
algorithms a. Very easy
b. Usually considered difficult P-31
c. 3rd Option is missing
d. 4th Option is missing
16. _____ of reference is an important fact of current processor technology.
a. Defining
b. Assigning
c. Formality
d. Locality P-8
17. 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
AL-JUNAID INSTITUTE OF GROUP
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
c. Two nearly equal pieces
d. Three nearly equal pieces
19. Which of the following is calculated with Big O notation?
a. Medium bounds
b. Upper bounds Page - 25
c. Lower bounds
d. Both upper and lower bounds
20. Edit distance algorithm based on ________ strategy
a. Greedy
b. Dynamic Programming Page - 81
c. Divide and Conquer
d. Searching
21. In Heapsort Algorithm, total time taken by heapify procedure is ________
a. O (log n) Page-43
b. O (log2 n)
c. O (n log n)
d. O (n2 log n)
22. Al-Khwarizmi was a/an _______
a. Artist
b. Mathematician P-7
c. Astronomer
d. Khalifah
23. When matrix A of 5x3is multiply with metric B of 3x4 then the
number of multiplication required is: Not found exactly
a. 15
b. 12
c. 36
d. 60 Not Found exactly but as per formula at page 84,
AL-JUNAID INSTITUTE OF GROUP
24. Pseudo code of algorithms are to be read by _______.
a. People Page -12
b. RAM
c. Computer
d. Compiler
25. The sieve technique is a special case, where the number of sub-problems is Just
_________
a. 1 P-34
b. 2
c. 3
d. 4
26. When a recursive algorithm revisits the same problem over and over
again, we say that the optimization problem has ________ sub-problems.
a. Overlapping – Google Search
b. Over costing
c. Optimized
d. Three
27. Sieve technique is very important special case of Divide-and-Conquer strategy.
a. True P-34
b. False
28. 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 P-10
29. Merge sort is based on _______.
a. Brute-force
b. Plan-sweep
c. Axis-sweep
d. Divide and Conquer P-27
AL-JUNAID INSTITUTE OF GROUP
30. 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) Google Search 31. In Heap Sort


31. algorithm, the first step is to ___________.
a. Call Build-Heap procedure Page - 46
b. Sort the array in descending order
c. Call Heapify procedure
d. Find the number of input elements
32. The definition of theta-notation relies on proving ________ asymptotic bound.
a. One
b. Lower
c. Upper
d. Both lower & upper Page - 25
33. In merge sort algorithm, to merge two lists of size n/2 to a list of size n, takes
_______ time.
a. Theta (n) Page - 32
b. Theta log(n)
c. Theta log2(n)
d. Theta n log(n)
34. We can make _______ recursive calls in Fibonacci Sequence.
a. Infinite
b. Finite google
c. Only one
d. Zero
35. Following is NOT the application of Edit Distance problem.
a. Speech recognition
b. Spelling Correction
c. Ascending Sort Page - 76
d. Computational Molecular Biology
AL-JUNAID INSTITUTE OF GROUP
36. In plane sweep approach, a vertical line is swept across the 2d-
plane and structure is used for holding the maximal points lying
to the left of the sweep line.
a. Array
b. Queue
c. Stack Page - 18
d. Tree
37. When a heapify procedure is applied to the root node to restore the
heap, then at each level, the comparison performed takes time:
a. It will take (log n).
b. It can not be predicted
c. It will take O (1). Page - 43
d. Time will vary according to the nature of input data.
38. _____ time is the maximum running time over all legal inputs.
a. Worst-case Page - 13
b. Average-case
c. Best-case
d. Good-case
39. Efficient algorithm requires less computational...
a. Memory
b. Running Time
c. Memory and Running Time Page - 9
d. Energy
40. 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 Page - 50
c. Pivot is input separately
d. values greater than 5
41. Selection algorithm takes theta ______
a. (n2)
b. (n) Page - 37
c. log(n)
d. n log(n)
AL-JUNAID INSTITUTE OF GROUP

42. Recurrence can be described in terms of a tree.


a. Yes Page - 31
b. No
43. 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) Page -90
44. The Iteration method is used for ______
a. Comparing sorting algorithms only
b. Solving Recurrence relations Page 31
c. Merging elements in Merge sort
d. Dividing elements in Merge sort
45. In 3-Dimensional space, a point P has ______ coordinate(s).
a. (X, Y)
b. (X, 0)
c. (0, Y)
d. (X,Y, Z)
46. Chain matrix multiplication problem can be solved through ______ strategy.
a. Dynamic programming Page - 85
b. Greedy
c. Divide and conquer
d. Sorting
47. Merge sort have running time....running time of Heap sort. Not found exactly
a. Greater than
b. Less than Google
c. Equal to
d. Different than
48. 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 Page – 34
AL-JUNAID INSTITUTE OF GROUP
49. We do not need to mathematically prove that for comparison-
based sorting algorithms always takes Omega nlog (n) time.
a. True Google & VU Tech (pg 46 not very clear)
b. False
50. The Omega-notation allows us to state only the asymptotic ______ bounds.
a. Middle
b. Lower Page 25
c. Upper
d. Both lower & upper
51. Both lower & upperSorting can be in ________
a. Increasing order only
b. Decreasing order only
c. Both Increasing and Decreasing order GOOGLR Search
d. Random order
52. Radix sort performs sorting the numbers _______ digit (s) at a time.
a. One Page - 71
b. Two
c. Three
d. All
53. Quicksort is a/an ______ and ________ sorting algorithm.
a. Not in place, not stable one
b. In place , not stable one Page - 54
c. In place , stable one
d. Not in place , stable one
54. Consider three matrices X,Y,Z of dimensions 1x2, 2x3,3x4
respectively. The number of multiplications of (XY) Z is:
a. 18 As per lecture slides
b. 32
c. 24
d. 30
55. In Fibonacci Sequence, unnecessary repetitions do not exist at all.
a. True
b. False Page – 74
AL-JUNAID INSTITUTE OF GROUP
56. It is not a Fibonacci sequence . 1,1,1,2,3,5,8,13,21,34,55,…..
a. True Page - 73
b. False
57. Heap sort is a/ an ______ and ________ sorting algorithem.
a. Not in place, not stable one
b. In place , not stable one Page - 54
c. In place , stable one
d. Not in place , stable one
58. Identify the True Statement
a. The knapsack problem does not belong to the domain of
optimization problems.
b. The knapsack problem belongs to the domain of optimization
problems. Page - 91
c. The Knapsack problem cannot be solved by
using dynamic programming
d. The knapsack problem is optimally solved by using
brute force algorithm.
59. In Dynamic Programming, our approach is to _________
a. Develop the solution in a top-down fashion
b. Express the problem non-recursively
c. Build the solution in a bottom-up fashion Page - 75
d. Input several sub-problems simultaneously
60. Counting sort is suitable to sort the elements in range 1 to K;
a. K is large
b. K is small Page - 57
c. K may be large or small
d. None
61. We can multiply two matrices A and B only when they are
compatible which means
a. Number of columns in A must be equal to number of rows in B.
it seems Correct as per page 84
b. Number of rows and columns do not matter
AL-JUNAID INSTITUTE OF GROUP
c. Number of columns in A must be equal to number of columns in B
d. Number of rows in A must be equal to number of rows in B
62. Matrix multiplication is a (n) ________ operation.
a. Commutative
b. Associative Page 85
c. Neither commutative nor associative
d. Commutative but not associative
63. In Dynamic Programming approach, solution is modified / changed
a. Always once
b. At each stage google and wikipedia
c. Only for specific problems
d. At 4th stage only
64. 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 Page - 91
d. None of the given options
65. An in-place sorting algorithm is one that ________ uses
additional array for storage.
a. Always
b. Permanently
c. Does not Page - 54
d. Sometime
66. Memoization is a part of Dynamic Programming Strategy.
a. True Page - 74
b. False
67. If matrix A of dimension 2x4 is multiply with matrix B of dimension 4x3, then
the dimension of resultant matrix is Not found exactly
a. 2x4
b. 4x3
c. 3x4
d. 2x3 It seems correct as per second last Para of page 84
AL-JUNAID INSTITUTE OF GROUP
68. In Dynamic Programming approach, we do not store the solution
to each sub-problem in case if it reappears.
a. True
b. False Page - 75
69. Dynamic Programming is a problem-solving approach in which___
a. Problem is solved in Zero time
b. Solution is developed only at final stage
c. Both are correct
d. Both are incorrect google
70. In Fibonacci sequence, each term is calculated by____ previous__ terms.
a. Subtracting, Two
b. Adding, Three
c. Adding, Two Page - 73
d. Multiplying, Two
71. Selection sort is not an in-place sorting algorithm.
a. True Page - 54
b. False
72. If there are θ (n2) entries in edit distance matrix then the total running time is:
a. θ (n)
b. θ (1)
c. θ (n2) Page – 84
d. θ (n logn)
73. 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 Page - 78
74. Dynamic programming formulation of the matrix chain multiplication
problem will store the solutions of each sub problem in an
a. Array
b. Table Page - 86
c. Variable
d. class
AL-JUNAID INSTITUTE OF GROUP
75. We can use the optimal substructure property to devise a
formulation of the edit distance problem.
a. Selective
b. Optimum
c. Iterative
d. Recursive Page - 78
76. Sorting is performed on the basis of ___________.
a. Computational resources
b. Asymptotic notation
c. Summation
d. Some key value of attribute page- 39
77. In Heap Sort algorithm, we call Build-heap procedure ____________.
a. Only once page 46
b. Twice
c. Thrice
d. As many times as we need
78. Radix sort is not a non-comparative integer sorting algorithm.
a. True Google Search
b. False
79. In the statement “output P[1].x, P[1].y”, the number of times
elements of P are accessed is _______.
a. 1
b. 2 page 14
c. 3
d. 4
80. The main purpose of mathematical analysis is measuring the
______ required by the algorithm.
a. Space
b. Execution time P-13
c. Inputs & outputs
d. Execution time and memory
AL-JUNAID INSTITUTE OF GROUP
81. _______ provides us more accurate result when input values are
not closer with each other
a. Average
b. Median P-34
c. Mode
d. Mean
82. The process of ______ ends when you are left with such tiny
pieces remaining that it is trivial to solve them.
a. Brute-force
b. Plan-sweep
c. Divide and Conquer P-27
d. Axis-sweep
83. __________ overcomes the limitations of _______ by
working as per positional notations of numbers.
a. Counting sort, Radix sort
b. Radix sort, Counting sort P-71
84. Memorization is a part of Dynamic Programming strategy.
a. True P-74
b. False
85. Rank of an element can be defined as ___________.
a. One minus the number of elements that are smaller
b. Two plus the number of elements that are greater
c. One plus the number of elements that are smaller P-34
d. Two minus the number of elements that are smaller
86. If the time complexity of an algorithm is given by O (1),
then its time complexity would be
a. Polynomial
b. Exponential
c. Constant - Wikipedia
d. Average
87. Quick sort is a recursive algorithm.

a. True Wikipedia ; Google


b. False
AL-JUNAID INSTITUTE OF GROUP
88. The asymptotic growth of n(n+1)/2 is:
a. O(n2) As the n^2 term has the largest contribution, the Big-O complexity is O(n^2)
b. O(n)
c. O(n+2)
d. O(n log n)
89. Approach of solving geometric problems by sweeping a line
across the plane is called _____ sweep.
a. Line
b. Plane Page 18
c. Cube
d. Box
90. As per algorithm of Dynamic Programing, we need to store
a. First sub-problem only
b. Best solution only
c. Intermediate sub-problems Pg:75
d. Final solution only
91. In Sieve technique, we solve the problem
a. In recursive manner Pg:34
b. Non recursively
c. Using Merge Sort algorithm
d. Using Brute force technique
92. One of the limitation in 0/1 knapsack is that an item can either be
________ in the bag or not.
a. Use
b. Put Pg:91
c. Move
d. Store
93. Which one is not passed as parameter in Quick sort algorithm?
a. End of the array
b. Middle of the array
c. Array (containing input elements) Google
d. Start of the array
AL-JUNAID INSTITUTE OF GROUP
94. In the analysis of Selection algorithm, we get the convergent _________
a. Harmonic
b. Linear
c. Arithmetic
d. Geometric Pg:37
95. A Random Access Machine (RAM)is an idealized machine
withrandom access memory.
a. Infinite large Pg:10
b. 512 MB
c. 256 MB
d. 2 GBs
96. While analyzing Selection algorithm, we make a number of
passes, in fact it could be as many as
a. n(n+1)
b. log(n) Pg:37
c. n/3
d. n/4
97. In Random Access Machine (RAM), instructions are executed in
a. Parallel
b. Batch
c. One by One Pg:10
d. Multiple times
98. In selection problem, the rank of an element will be its ________ position
a. First
b. final Pg:34
c. Second last
d. Last
99. The worst-case running time of Merge sort is _____ in order to
sort an array of n elements.
a. O(log n)
b. O(n)
c. O(n log n) page 40 and google
d. O(n)
AL-JUNAID INSTITUTE OF GROUP
100. f(n) and g(n) are asymptotically equivalent. This means
that they have essentially the same ______.
a. Results
b. Variables
c. Size
d. Growth rates P:23
101. An algorithm is a mathematical entity. Which is independent of _______.
a. Programming language
b. Machine and Programming language
c. Compiler and Programming language
d. Programming language Compiler and Machine P:07
102. In Quick sort algorithm, Pivots form ___
a. Stack
b. Queue
c. Binary Search Tree P:49
d. Graph
103. Counting sort is suitable for sorting the elements within range 1 to P. where
a. P is large
b. P is small P-57
c. P is very large
d. P is undetermined
104. 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
105. ___ Items are not allowed in the 0/1
knapsack. a. Lighter
b. Fractional P-91
c. Whole
d. Weighty
AL-JUNAID INSTITUTE OF GROUP
106. Fibonacci Sequence was named on ______, a famous
mathematician in 12th Century.
a. Fred Brooks
b. Grady Booch
c. Leonardo Pisano P-73
d. Edgar F. Codd
107. In Heap Sort algorithm, we build _____ for ascending sort.
a. Max heap P-41
b. Min heap
108. Bubble sort is not an in-place sorting algorithm.
a. True
b. False P-54
109. In partition algorithm, the subarray ______ has elements
which are greater than pivot element x.
a. A[p...r]
b. A[p...q-1]
c. A[q]
d. A[q+1..r] P-46
110. In Heap Sort algorithm, if heap property is violated
a. We call Build heap procedure P-43
b. We call Heapify procedure
c. We ignore
d. Heap property can never be violated
111. ______ is not a characteristic of Random Access Machine.
a. Single-Processor P-10
b. Assigning a value to a variable
c. Locality of reference
d. Executing an arithmetic instruction
112. The only way to convert an empty string into a sting of j
characters is by doing j insertions, represented as ______
a. E(i,j) = 1
b. E(I,0) = I
c. E(0,j) = j page 78
d. E(1,j)= j
AL-JUNAID INSTITUTE OF GROUP

113. In Selection problem, the Sieve technique works in __________.


a. Non-recursive manner
b. Constant time
c. Phases page 34
d. One complete go
114. Algorithm is a sequence of computational steps that ----
the input into output.
a. Merge
b. Assign
c. Transform page 7
d. Integrate
115. If pj dominates pi and pi dominates ph then pj also dominates
ph, it means dominance relation is
a. Transitive page 18
b. Non Transitive
c. Equation
d. Symbolic
116. 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
117. In the following code the statement “cout<<j;”executes ----
----- times. for (j=1; j<=5; j = j+2)
cout<<j;
a. 5 times
b. 2 times
c. 3 times
d. 0 times
AL-JUNAID INSTITUTE OF GROUP
118. In merge sort algorithm, we split the array around the
______ index q. a. Entring
b. Mid page 17
c. Exiting
d. Summing
119. In Selection problem, the Sieve technique _________.
a. Add some more input items each time
b. Do not work recursively
c. Do not uses Divide and Conquer approach
d. Eliminates undesired data items each time
120. Consider three matrices X, Y, Z of dimensions 1 x 2, 2 x 3,
3 x 4 respectively. The number of multiplications of X(YZ) is .
a. 16
b. 32
c. 26
d. 32 page 84
121. In Heap Sort algorithm, the total running time for Heapify procedure is
_______
a. Theta (log n)
b. Order (log n)
c. Omega (log n)
d. O(1) i.e. Constant time
122. The sieve technique works where we have to find_______
items(s) from a large input.
a. Single page 34
b. Two
c. Three
d. Similar
123. In Dynamic Programming based solution of Knapsack Problem,
if we decide to take an object i , then we gain______
a. W(Total Weight of Knapsack)
b. V (Total Value of all items)
c. vi (Value of object i) page 93
d. Nome of the given option
AL-JUNAID INSTITUTE OF GROUP
124. While Sorting, the order domain means for any two input elements x and y
_______ satisfies only.
a. x < y page 39
b. x > y
c. x = y
d. All of the above
125. For solving Selection problem, we introduced Sieve technique due to
_______
a. Using Decrease and Conquer strategy page 34
b. Avoiding to sort all input data
c. Eliminating Rank of an element
d. Using Brute-force approach
126. ________ is one of the few problems, where provable lower
bounds exist on how fast we can sort.
a. Searching
b. Sorting page 38
c. Both Searching & sorting
d. Growing
127. In plane sweep approach, a vertical line is swept across
the 2d-plane from_____.
a. Right to Left
b. Left to Right page 18
c. Top to Bottom
d. Bottom to top
128. In generating Fibonacci sequence, we can avoid unnecessary repetitions by
_____ process.
a. Tokenization
b. Memorization page 43
c. Randomization
d. Memorization
129. For _________ values of n, any algorithm is fast enough.
a. Small page 14
b. Medium
c. Large
d. Infinity
AL-JUNAID INSTITUTE OF GROUP
130. Dynamic programming comprises of _______.
a. Recursion only
b. Repetition only
c. Recursion with Repetition
d. No Repetition but Recursion page 75
131. The function f(n)=n(logn+1)/2 is asymptotically equalient t nlog n :Here Lower
Bound means function f(n) grows asymptotically at __ as fast as nlog n.
a. Least page 23
b. Normal
c. Most
d. At
132. Counting sort has time complexity.
a. O(n+k)
b. O(n) page 58
c. O(k)
d. O(nlogn)
133. Due to left complete nature of binary tree, the heap can be stored in
a. Array page 40
b. Structures
c. Link List
d. Stack
134. Single item from a larger set of ________.
a. Constant
b. Pointers
c. Phases
d. n items page 34
135. 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 page 76
AL-JUNAID INSTITUTE OF GROUP
136. How much time merge sort takes for an array of numbers?
a. T(n^2)
b. T(n)
c. T(log n)
d. T(n log n) page 40
137. In in-place sorting algorithm is one that uses arrays for storage.
a. No additional array page 54
b. An additional array
c. Both of above may be true according to algorithm
d. More than 3 arrays of one dimension
138. Brute-force algorithm for 2D-Maxima is operated by comparing ______
pairs of points.
a. Two
b. Some
c. Most
d. All page 18
139. While Sorting, the ordered domain means for any two input
elements x and y ____ satisfies only.
a. x > y
b. x < y
c. x = y
d. All of the above page 38
140. Quick sort is.
a. Stable & in place
b. Not stable but in place page 54
c. Stable but not in place
d. Some time stable & some times in place
141. Which may be a stable sort?
a. Merger
b. Insertion
c. Both above page 54
d. None of the above
AL-JUNAID INSTITUTE OF GROUP
142. For the Sieve Technique we take time.
a. T(nk) page 34
b. IT(n / 3)
c. n^2
d. n/3
143. Continuation sort is suitable to sort the elements in range 1 to k.
a. K is Large
b. K is not known
c. K may be small or large
d. K is small page 54
144. Asymptotic growth rate of the function is taken over ______
case running time. .
a. Best
b. Worst page 14
c. Average
d. Normal
145. The sieve technique is a special case, where the number of
sub problems is just.
a. 5
b. Many
c. 1 page 34
d. Few
146. In Quick sort, we don’t have the control over the sizes of recursive calls.
a. True page 49
b. False
c. Less information to decide
d. Ether true or false
147. Before sweeping a vertical line in plane sweep approach, in start sorting
of the points is done in increasing order of their _____ coordinates. .
a. X page 18
b. Y
c. Z
d. X , Y
AL-JUNAID INSTITUTE OF GROUP
148. Random access machine or RAM is a/an.
a. Machine build by Al-Khwarizmi
b. Mechanical machine
c. Mathematical model page 10
d. Electronics machine
149. The Huffman codes provide a method of encoding data
inefficiently when coded using ASCII standard.
a. True
b. False page 99
150. A heap is a left-complete binary tree that confirms to the ________.
a. increasing order only
b. decreasing order only
c. heap order page 40
d. log n order
151. If we associate (x, y) integers pair to cars where x is the speed of the car and
y is the negation of the price. High y value for a car means a ________ car.
a. Fast
b. Slow
c. Expensive
d. Cheap
152. Which one of the following sorting algorithms is the fastest?
a. Merge sort
b. Quick sort
c. Insertion sort
d. Heap sort
153. Quick sort algorithm divide the entire array into ________ sub arrays.
a. 2
b. 3
c. 4
d. 5
154. In brute force algorithm, we measure running time T(n) based on ________.
a. Average-case time and best-case time
b. Worst-case time and average-case time page 46
c. Worst-case time and best-case time
d. Best-case time and staring-case time
AL-JUNAID INSTITUTE OF GROUP
155. 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
156. There are ________ entries in the Edit Distance Matrix
a. ϴ (n)
b. ϴ (n2) page 84
c. ϴ (n+2)
d. ϴ (n + 100)
157. Which symbol is used for Omega notation?
a. (O)
b. (ϴ)
c. (Ω)
d. (@)
158. Selection sort is a ______ sorting algorithm
a. In-place page 54
b. Not In-Place
c. Stable
d. in-partition
159. In Dynamic Programming based solution of knapsack problem,
to compute entries of 'V', we will imply a(n) ______ approach.
a. Subjective
b. Inductive
c. Brute Force
d. Combination
160. We do not need to prove comparison-based sorting
algorithms by mathematically. It always takes _________ time.
a. Big Oh nlog(n)
b. Omega nlog(n) NOT SURE
c. Omega n(n^2)
d. Theta nlog(n)
AL-JUNAID INSTITUTE OF GROUP
161. Merge sort is a/an _______ and ________ sorting algorithm
a. Not in-place, not stable one
b. In-place, not stable one
c. In-place, stable one
d. Not in-place, stable one page 54
162. Cubic function will ________ a quadratic function.
a. Prove
b. be equal to
c. overtake Page 25
d. find
163. Insertion sort is a _________ sorting algorithm
a. Unstable
b. In-place Page 54
c. Not In-Place
d. in-partition
164. 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
165. Asymptotic growth of 8n^2 + 2n – 3 is:
a. Θ(n^2 + n)
b. Θ (n^2) page 14
c. Θ(8n^2)
d. Θ(8n^2 + 2n)
166. In the analysis of algorithms, _________ plays an important role.
a. text analysis
b. time
c. growth rate
d. money
AL-JUNAID INSTITUTE OF GROUP
167. In inductive approach of knapsack problem, we consider 2 cases, _______
Or ________.
a. Median, Mode
b. Recursive, Iterative
c. Leave object, Take object page 93
d. Sequentially. Parallel
168. Random Access Machine (RAM) can execute _________ instructions
a. only logical
b. parallel
c. only arithmetic
d. logical and arithmetic
169. Using _______ algorithm, efficiency is not given much importance
a. Greedy
b. Merge sort
c. Processing as there is no algorithm by this name
d. Brute Force
170. Bubble sort takes theta _________ in the worst case
a. (n2) page 39
b. (n)
c. log(n)
d. nlog(n)
171. If matrix A of dimension p × q is multiply with matrix B of
dimension q × r, then dimension of resultant matrix is:
a. p × q
b. p × r page 84
c. q × r
d. r × p
172. Dynamic Programing algorithms often use some kind of
________ to store the results of intermediate sub-problems
a. table (Page 75)
b. variable
c. stack
d. loop
AL-JUNAID INSTITUTE OF GROUP
173. ________________ is in-place sorting algorithm.
a. Bubble sort (Page 54)
b. Merge sort
c. Linear search
d. Binary Search
174. Which one of the following problems can be solved using dynamic problem?
a. Bubble sort problem
b. Matrix chain multiplication problem page 85
c. Greedy search problem
d. Fractional knapsack problem
175. In chain matrix multiplication, solutions of the sub-problems are stored in a
_________.
a. Array
b. Table page 86
c. Tree
d. Link list
176. What is the average running time of a quick sort algorithm?
a. O(n^2)
b. O(n)
c. O(n log n) (Page 49)
d. O(log n)
177. Sorting Algorithms having O _______ running time are
considered to be slow ones.
a. (n)
b. (n^2) (Page 39)
c. (nlog(n))
d. (log(n))
178. While solving Selection problem, in Sieve technique we partition input data
________
a. In increasing order
b. In decreasing order
c. According to Pivot
d. Randomly
AL-JUNAID INSTITUTE OF GROUP
179. ________ 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. Memoization page 74
c. Recursion
d. Function
180. In average-case time the probability of seeing input is denoted by _______.
a. p{I}
b. p[I]
c. p<i>
d. p(i) page 13
181. While applying the Sieve technique to selection sort, how to
choose a pivot element.
a. Through mean
b. Linear
c. Randomly page 35
d. Sequentially
182. Number of _______ of the pseudo code are counted to measure
the running time.
a. Inputs
b. Outputs
c. Steps page 13
d. Pages
183. Developing a dynamic programming algorithm generally involves ______
separate steps.
a. One
b. Two page 75
c. Three
d. Four
184. 8n^2+2n+3 will exceed c28(n), no matter how large we make _____.
a. n
b. 2n
c. c2 page 25
d. this quadratic equation
AL-JUNAID INSTITUTE OF GROUP
185. The running time of quick sort algorithm_________.
a. Is impossible to compute
b. Has nothing to do with pivot selection
c. Is Random upon each execution
d. Greatly influenced by the selection of pivot page 49
186. _________ involves breaking up the problem into sub problems
whose solutions can be combined to solve the global problem.
a. Complexity Theory
b. Dynamic programming solution
c. Divide and Conquer Strategy page 34
d. Greedy Algorithms
187. In _____________ we have to find rank of an element from given input.
a. Merge sort algorithm
b. Selection problem page 34
c. Brute force technique
d. Plane Sweep algorithm
188. How many steps are involved to design the dynamic programming strategy?
a. 2
b. 3
c. 1
d. 4 page 92
189. In Bucket sort, if there are duplicates then each bin can be
replaced by a a. Stack
b. Linked list page 69
c. Hash table
d. Heap
190. In merge sort algorithm, we split the array ______ to find index q.
a. from start
b. midway page 28
c. from end
d. both from start or end
AL-JUNAID INSTITUTE OF GROUP
191. 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. 280
b. 100
c. 90
d. 200
192. In 2-d maxima problem a point p is said to be dominated by point q if
_________.
a. p.x <= q.x
b. p.x <= q.x and p.y <= q.y page 17
c. p.y <= q.y
d. p.x >= q.x and p.y >=q.y
193. Sorting can be in ______________.
a. Increasing order only
b. Decreasing order only
c. Both increasing and decreasing order
d. Random order
194. Recurrence can be described in terms of _______________.
a. Array
b. Linear
c. Tree page 31
d. Graph
195. The brute-force algorithm for 2D-Maxima runs in order O(__) time.
a. n
b. n(log n)
c. n*n page 18
d. n3
AL-JUNAID INSTITUTE OF GROUP
196. In plane sweep approach of solving geometric problems, a
_________ is swept across the plane.
a. Line page 18
b. Plane
c. Cube
d. Box
197. Which of the following is calculated with Big Omega notation?
a. Medium bounds
b. Upper bounds
c. Lower bounds Page - 25
d. Both upper and lower bounds
198. _________ is always based on divide and conquer strategy.
a. Bubble sort
b. Selection sort
c. Pigeon sort
d. Quick sort page 46
199. If a matrix has three rows and two columns, then dimensions
of matrix will be:
a. 3x2
b. 2x3
c. 3x3
d. 2x2
200. Asymptotic notations are used to describe _______ of an algorithm.
a. Length
b. running time google
c. size
d. compile time
201. Catalan numbers are related the number of different ______ on ‘n’ nodes.
a. Arrays
b. linked lists
c. binary trees page 85
d. functions
AL-JUNAID INSTITUTE OF GROUP
202. Applying the sieve technique to selection problem, ________
element is picked from array.
a. Output
b. Total
c. Input
d. Pivot page 35
203. Dynamic Programming approach is usually useful in solving _______
problems.
a. Normal
b. Optimization google
c. Array
d. Loop
204. In recursive formulation of knapsack
Problem: V [0, j] = ________ for j>=0
a. -1
b. 0 page 93
c. 1
d. 2
205. ________ is a linear time sorting algorithm.
a. Merge sort
b. Radix sort page 71
c. Quick sort
d. Bubble sort
206. Quick sort is one of the _____ sorting algorithm.
a. Fastest page 19
b. Slowest
c. Major
d. Average
207. The time assumed for each basic operation to execute on
RAM model of computation is _____.
a. Infinite
b. Continuous
c. Constant page 10
d. Variable
AL-JUNAID INSTITUTE OF GROUP

208. In Sieve Technique, we know the item of


interest. a. True
b. False page 34
209. While analyzing algorithms, _______ and _______ usually
considered difficult to calculate.
a. Finite, Infinite
b. Floor, ceiling google
c. Row, Column
d. Graph, Tree
210. While analysis of the brute-force maxima algorithm, an array
sorted in the reverse order is the type of _________ case input.
a. Best
b. Worst page 14
c. Somewhat bad
d. Average
211. _________ is not useful measure of central tendency of given
input set especially when the distribution of values is highly skewed.
a. Mean
b. Mode
c. Average
d. Median page 34
212. In asymptotical analysis of n(n-3) and 4n*n, as n becomes large,
the dominant (fastest growing) term is some constant times _______.
a. n+1
b. n-1
c. n
d. n*n page 23
213. In addition to passing in the array itself to Merge Sort
algorithm, we will pass in other arguments which are indices.
a. Two P-38
b. Three
c. Four
d. Five
AL-JUNAID INSTITUTE OF GROUP
214. 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 P-11
d. Joint
215. Counting sort assumes that the numbers to be sorted are in the range
________.
a. K to n where n is large
b. 1 to k where k is small (P-57)
c. K to n where k is small
d. k to n where n is small
216. Insertion sort is an efficient algorithm for sorting a
__________ number of elements
a. Large P-39
b. Small
c. Extra large
d. Medium
217. If the indices passed to merge sort algorithm are _________
then this means that there is only one element to sort.
a. Small page 28
b. Large
c. Equal
d. Not Equal
218. In Knapsack Problem, each item must be entirely accepted
or rejected, is called ______ problem.
a. Fractional
b. 0-1 P-92
c. Linear
d. Optimal
AL-JUNAID INSTITUTE OF GROUP
219. If the time complexity of an algorithm is O(n). then it is called
_______ time complexity.
a. Linear Wikipedia
b. Constant
c. Average
d. Exponential
220. In the case of _________ analysis does not depend upon on
the distribution of input.
a. Merge sort
b. Quick sort P-50
c. Insertion sort
d. Heap sort
221. 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 page 78
222. The following sequence is called ____________
1,2,3,5,8,13,21,34,55,…..
a. Optimize sequence
b. Fibonacci sequence page 73
c. Optimal sequence
d. Overlapping sequence
223. Which one sorting algorithm is best suited to sort an array
of 2 million elements?
a. Bubble sort
b. Insert sort
c. Merge sort
d. Quick sort
e. Ridx Sort page 71
AL-JUNAID INSTITUTE OF GROUP
224. We can improve the performance of quick sort if we could
be able to _,__________.
a. Skip input elements somehow
b. Select two or more pivots page 34
c. Skip any sub-array completely
d. Eliminate recursive calls
225. The problem with the brute-force algorithm is that is uses
________ in pruning out de
a. Worst-case time
b. No intelligence page 18
c. Outside looping
d. Artificial intelligence
226. In chain matrix multiplication, the order of the matrices __________.
a. Can be changed
b. Can not be changed page 85
c. is equal
d. is reverse
227. In quick sort algorithm, we choose pivot___________.
a. Always the smallest element
b. Greater than 5
c. Randomly page 35
d. Less than 5
228. In Heap Sort algorithm. Heapify procedure is ________ in nature.
a. Recursive
b. Non-Recursive page 43
c. Fast
d. Slow
229. When matrix A of 5x 3 is multiplied with matrix B of 3 x 4 then
the number of multiplications required will be ___________.
a. 15
b. 12
c. 36
d. 60
AL-JUNAID INSTITUTE OF GROUP
230. An algorithm is said to be correct if for every ______ instance,
it halts with the correct ______.
a. Input, Output page 13
b. Design, Analysis
c. Value, Key
d. Key, Analysis
231. 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 page 86
232. If we have an equation 8n2+7f*n + 5f + 6 then is large, ________ term
will be muchxxxxxxxthe n term and will dominate the running time.
a. f g (n)
b. g (n) * 2
c. n * 2 page 23
d. f (n)
233. For quick sort algorithm. Partitioning takes theta ________.
a. (n)
b. log(n)
c. n log (n)
d. n2log (n)
234. In Heap Sort algorithm, the maximum levels an element can move upward is
_______
a. Theta (log n) page 43
b. Big-ch (log n)
c. Omega (log n)
d. 0 (1) i.e. Constant time
235. _______ programming is essentially recursion without repetition.
a. Fast
b. Dynamic page 75
c. Array
AL-JUNAID INSTITUTE OF GROUP
d. n (log n)
236. In heap sort algorithm, the total running time for heavily
procedure is _.
 Big-oh(log n)
 O (1) i.e. Constant time
 Theta (log n)
 Omega (log n)
237. Quick sort algorithm is required a lot of comparison in the ____
condition.
 Worse case
 Best and average case
 Average case
 Best case
238. In heap sort algorithm (using max heap). When every time
maximum element is removed from top.
 Divide and conquer strategy helps us
 We are left with a lot
 We call merge sort algorithm
 It becomes order n2 algorithm
239. In average-case time analysis of quick sort algorithm,
The most balanced case for partition is where we divide the list of
element into ________
 Three nearly equal pieces
 Single piece exactly
 Two nearly piece
 Equal no. of piece as of input element
240. Consider three matrices X,Y,Z dimensions 1×2.2×.3×4
respectively. The number of multiplication of (XYZ) is:
 32
 30
AL-JUNAID INSTITUTE OF GROUP
 24
 18
241. Quicksort is a/an _____ and______ sorting algorithm.
 In-place, not stable one
 Not in-place, stable one
 In-place, stable one
 Not in-place, not stable one
242. ________items are not allowed in the 0/1 knapack.
 Lighter
 Whole
 Weighty
 Fractional
243. The main purpose of mathematical analysis is measuring the
______ required by the algorithm.
 Space
 Execution time and memory
 Input & output
 Execution time
244. Execution time of an algorithm can be measured by __________.
 Divide and conquer approach
 Both brute force and divide and conquer approach
 Mathematical analysis
 Brute force approach
245. Quick sort is based on ________ strategy.
 Graph theory
 Divide-and-conquer
 Dynamic programming
 Greedy approach
246. A sorting algorithm is called as ______ if duplicate element
remain in the same relative position after sorting.
AL-JUNAID INSTITUTE OF GROUP
 O(n) algorithm
 Stable
 Parallel
 Complex
247. Which one sorting algorithm is best suited to sort an array of 2
million elements?
 Insert sort
 Quick sort
 Merge sort
 Bubble sort
248. We can use the ___________ property to devise a recursive
formulation of the edit distance problem.
 Algorithm
 Small substructure
 Optimal substructure
 Real
249. While sorting. The ordered domain means for any two input
elements x and y ________ satisfies only.
 All of the above
 x>y
 x<y
 x=y
250. 8n2 + 2n -3 will eventually exceed c2*(n) no matter how large
we make _____.
 2n
 n
 this equation
 c2
251. ________ is a method of solving a problem in which we check
all possible solution to the problem to find the solution we need.
AL-JUNAID INSTITUTE OF GROUP
 Sorting algorithm
 Greedy approach
 Plane-sweep algorithm
 Brute-force algorithm
252. In quick sort algorithm, provost form ________.
 Graph
 Stack
 Binary search tree
 Queue
253. In asymptotical analysis of n(n -3) and 4n*n, as n becomes large,
the dominant (fastest growing) term is some constant time_______
 n +1
 n*n
 n
 n-1
254. 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 Matrix-C having dimensions
 2×3
 2×2
 3×2
 3×3
255. Boolean operation is a ________ operation on an idealized RAM
model of computation.
 Advance
 Normal
 Basic
 Starting
256. There are __________ entries in the Edit Distance Matrix.
 ʘ (𝑛 )
AL-JUNAID INSTITUTE OF GROUP
 ʘ ( n+100)
 ʘ (n)
 ʘ (n+2)
257. Counting sort is suitable for sorting the elements within range 1
to P. where__________
 P is undetermined
 P is small
 P is very large
 P is large
258. Suppose we have 4 matrices A,B,C,D. what is correct
expansion of m[1,2] in chain matrix multiplication?
 m[1,2] = m[1,1] + m[2,2] +p0 . p1. p3
 m[1,2] = m[1,1] + m[2,2] +p0 . p1. p3
 m[1,2] = m[1,1] + m[2,2] +p0 . p1. p3
 m[1,2] = m[1,1] + m[2,2] +p0 . p1. p3
259. Which one is not passed as parameter in Quick Sort algorithm?
 Array (containing input elements)
 Middle of the array
 Start of the array
 End of the array
260. In asymptotical analysis of n*(5+2)-3. As n becomes large, the
dominant (fastest growing) term is some constant times______
 n+1
 n*n
 n
 n_1
261. For ______ values of n, any algorithm is fast enough.
 Medium
 Small
 Infinity
AL-JUNAID INSTITUTE OF GROUP
 Large
262. Dynamic programming algorithms often use some kind of
________ to store the result of intermediate sub-problems.
 Stack
 Loop
 Table
 Variable
263. In selection problem, the Sieve technique works in______
 One complete go
 Constant time
 Non-recursive manner
 Phases
264. In heap Sort algorithm, the maximum levels an element can move
upward is ___________.
 Theta (log n)
 O (1) i.e. Constant time
 Omega (log n)
 Big-oh (log n)
265. While analysis of the brute-force maxima algorithm, an array
storted in the reverse order is the type of _________ case input.
 Worst
 Best
 Somewhat
 Average

You might also like