CS502 Mid Term by JUANID
CS502 Mid Term by JUANID
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)