Muhammad Faisal: Mit 4 Semester
Muhammad Faisal: Mit 4 Semester
2. We do sorting to,
keep elements in random positions
keep the algorithm run in linear order
keep the algorithm run in (log n) order
keep elements in increasing or decreasing order (Handsouts Page 39 Line 6)
3. The reason for introducing Sieve Technique algorithm is that it illustrates a very
important special case of,
divide-and-conquer (handsouts page 34 )
decrease and conquer
greedy nature
2-dimension Maxima
9. One of the clever aspects of heaps is that they can be stored in arrays
without using any .
pointers (handsouts page 40)
constants
variables
functions
10. Sorting is one of the few problems where provable bonds exits on how fast
we can sort,
upper
lower (handsouts page 39)
average log n
2nd
13. How much time merge sort takes for an array of numbers? (n^2)
T(n)
T( log n)
T(n log n) (handouts page 30)
14. For the Sieve Technique we take time
T(nk) (handouts page 34)
T(n / 3) n^2
n/3
15. Heaps can be stored in arrays without using any pointers; this is due to the
nature of the binary tree,
left-complete Repeat
right-complete tree nodes
tree leaves
16. How many elements do we eliminate in each time for the Analysis of Selection
algorithm?
n / 2 elements
(n / 2) + n elements
n / 4 elements 2 n elements
20. In the analysis of Selection algorithm, we make a number of passes, in fact it could
be as many as,
T(n)
T(n / 2)
log n (page 37)
n/ 2 + n / 4
22. How much time merge sort takes for an array of numbers? T(n^2)
T(n)
T( log n)
T(n log n) (page 30)
24. n 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
25. Sieve Technique applies to problems where we are interested in finding a single item
from a larger set of
n items (page 34)
phases
pointers
constant
26. A (an) is a left-complete binary tree that conforms to the heap order
heap (page 40)
binary tree
binary search tree
array
29. For the heap sort, access to nodes involves simple operations.
arithmetic (page 41)
binary
algebraic
logarithmic
30. The analysis of Selection algorithm shows the total running time is indeed
in n
arithmetic
geometric
linear (page 37)
orthogonal
For the heap sort, access to nodes involves simple operations. Select
correct option:
Arithmetic (page 41)
binary
algebraic
logarithmic
One of the clever aspects of heaps is that they can be stored in arrays without using any
.
Pointers (page 40)
constants
variables
functions
Sorting is one of the few problems where provable bonds exits on how fast we
can sort,
upper
lower (page 39)
average log n
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
The analysis of Selection algorithm shows the total running time is indeed in n,
Select correct option:
arithmetic
geometric
linear Repeat
orthogonal
The sieve technique works in as follows
Phases Repeat
numbers
integers
routines
Sorting is one of the few problems where provable bonds exits on how fast we
can sort,
upper
lower Repeat
average
log n
A (an) is a left-complete binary tree that conforms to the heap order Select
correct option:
heap Repeat
binary tree
binary search tree array
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 Repeat
exponent
One of the clever aspects of heaps is that they can be stored in arrays without using any
.
Pointers Repeat
constants
variables
functions
Analysis of Selection algorithm ends up with,
The analysis of Selection algorithm shows the total running time is indeed in n
arithmetic
geometric
Linear Repeat
Orthogonal
Only i
Only ii
Both i and ii
Both iii and iv Ref (Merge sort and counting sort are stable algorithms)
Question No. 1
Assume that a given algorithm has a runtime C that depends on the size N of its
input
according to the following two formulas:
01
()
( 1) 2
if N
CN
C N if N
=
= −+> 2
Which of the following functions C(N) describes the runtime of the algorithm?
C(N) = N – 1
C(N) = (N - 1)2
C(N) = log2 N (Not Sure)
C(N) = 2(N - 1)
Question No. 7
Let us say we have an algorithm that carries out N2 operations for an input of size
N. Let us say that a computer takes 1 microsecond (1/1000000 second) to carry out
one operation.How long does the algorithm run for an input of size 3000?
90 seconds
9 seconds (Sure)
0.9 seconds
0.09 seconds
Question No. 8
Consider the following polynomial
aknk+ak-1nk-1+………….a0 .
What is the Big –O representation of the above polynomial?
O(kn)
O(nk) (Sure)
O(nk+1)
None of the above
2. Sieve Technique applies to problems where we are interested in finding a single item
from a larger set of
Select correct option:
>n items (page 34)
>phases
>pointers
>constant
gorithm.
> Asymptotic
>. Flowchart (rep)
this
>theata(n^3)
theata(4n^4+ 5n^3)
9. Counting sort the numbers to be sorted are in the range 1 to k where k is small.
>True (page 57)
>False
2 Solve the recurrence using iteration method and also find time complexity (Θ
notation)
T (n) = C + O (1) + T (n-1)
T (1) =1 and C is a constant.
5.In selection algorithm, because we eliminate a constant fraction of the array with
each phase, we get the
Convergent geometric series (page 37)
Divergent geometric series
None of these
Q2:_
If an algorithm has a complexity of log2n + nlog2n + n. we could say that it has
complexity
1)O(n)
2)O( n log2n) (page 106)
3)O(3)
4)O( log2( log2n )) 5)O ( log2n)
Q4
Due to left-complete nature of binary tree, heaps can be stored in Link list
Structure
Array (page 40) repeat
None of above
Q5
In selection algorithm, because we eliminate a constant fraction of the array with each
phase, we get the
Convergent geometric series (page 37)
Divergent geometric series None of these
Q#6
In RAM model instructions are executed
One after another (page 10)
Parallel
Concurrent
Random
Qus 7
Consider the following pairs of functions
I . f(x) = x + 3x+7 g(x) = x + 1022
II f(x) = x2log(x) g(x) = x3
III f(x) = x + log(3x +7) g(x) = (x48 2 +17x +3)2
Which of the pairs of functions f and g are asymptotic?
Only I not sure
Only II
Both I and III
None of the above
Q8
Execution of the following code fragment int Idx;
for (Idx = 0; Idx < N; Idx++)
{
cout << A[Idx] << endl;
}
is best described as being
O(N) sure
O(N2)
O(log N)
O(N log N)
Q9
If algorithm A has running time 7n2 + 2n + 3 and algorithm B has running time 2n2, then
Both have same asymptotic time complexity (see page 24)
A is asymptotically greater
B
None of others
Question No. 10
Which of the following sorting algorithms is stable?
Merge sort,
Quick sort,
Heap sort,
Counting Sort.
Only i
Only ii
Both i and ii
Both iii and iv
“Counting sort and merge sort are both stable algorithms “
Q11
Consider the following recurrence relation
2 if n = 0 T n( ) =?
6 (T n - 1) otherwise
Then T(2) is
? 36 not sure
72
12
None of the above
Q12
Let us say we have an algorithm that carries out N2 operations for an input of size N. Let
us say that a computer takes 1 microsecond (1/1000000 second) to carry out one
operation. How long does the algorithm run for an input of size 3000?
? 90 seconds ? 9 seconds
? 0.9seconds
? 0.09 seconds
Q13
The appropriate big ? classification of the given function. f(n) = 4n2 + 97n + 1000 is
? (n)
? (2n)
? (n2)
? (n2 log n)
Q14
Consider the following polynomial
aknk+ak-1nk-1+………….a0 .
What is the Big –O representation of the above polynomial?
O(kn)
O(nk)
O(nk+1)
None of the above
Q15
Consider the C++ program segment given below: for ( i=0 ; i < n; i++) {
for (j = 1,sum=a[0]; j < = i; j++) Sum+=a[j];
Cout<< “The sum for sub-array is<< sum;
}
The running time of the above algorithm is
n.
n log n .
log n .
n2.
Q16
Consider the following pairs of functions
I . f(x) = (x3 + x2 + x + 1)4 g(x) = (x4 +x3 + x2+ x + 1)3
II f(x) = 22x g(x) = 2x 2
III f(x) = 2x + 3 g(x) = 2x + 7
IV f(x) = log(x2 + 1) g(x) = log( x)
Which of the pairs of functions f and g are asymptotic?
Only I
Only III
Both I and II
Both III and IV
Question No. 5
Dynamic programming uses a top-down approach.
? True click here
? False
Question No. 6
The edit distance between FOOD and MONEY is
At most four (page 76)
At least four
Exact four
Question No. 7
Consider the following recurrence relation
4 if n = 1 T n( ) =?
Tn + 2
n if n is divisible by 5 ( n/ 5) 3
Then T(5) is
25 Not sure
75
79
None of the above
Question No. 10
Execution of the following code fragment int i = N;
while (i > 0)
{
int Sum = 0; int j;
for (j = 0; j < N; j++) Sum++;
cout << Sum << end; i--;
} is best described as being
O(N) Sure
O(N2)
O(log N) O(N
log N) Question
No. 11
It is impossible to design a sorting algorithm based on comparison of keys whose worst
case run time is in O(n).
? True
? False (page 55)
Question No. 12
Consider the following recurrence relation
5 if n = 1
T n( ) =? + if n is even
? 2 ( / 2) 3 Then T(8) is
61
29
13
None of the above Not sure
Question No. 13
The merge sort algorithm involves the following steps.
Recursively sort the 1st and 2nd halves separately
Merge the two-sorted halves into a sorted group.
If the number of items to sort is 0 or 1, return.
Which is the correct order of instructions in merge sort algorithm?
? (i),(ii),(iii)
? (ii),(iii),(i)
? (iii),(ii),(i)
? (iii),(i),(ii) (page 27)
Qus14
iterfib achieve an exponential speedup over the original recursive algorithm
True (page 75)
False
Q What type of instructions Random Access Machine (RAM) can execute? Choose
best
answer
Algebraic and logic
Geometric and arithmetic
Arithmetic and logic rep(Page 10)
Parallel and recursive
Q For Chain Matrix Multiplication we can not 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
3. 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
9. One of the clever aspects of heaps is that they can be stored in arrays without
using any .
pointers (page 40)
constants
variables
functions
10. Sorting is one of the few problems where provable bonds exits on how
fast we can sort,
upper
lower (page 39)
average
log n
2nd
13. How much time merge sort takes for an array of numbers?
(n^2)
T(n)
T( log n)
T(n log n) (page 40)
15. Heaps can be stored in arrays without using any pointers; this is due to the
nature of the binary tree,
left-complete (page 40)
right-complete
tree nodes
tree leaves
16. How many elements do we eliminate in each time for the Analysis of Selection
algorithm?
n / 2 elements (page 36)
(n / 2) + n elements
n / 4 elements
2 n elements
22. How much time merge sort takes for an array of numbers?
T(n^2)
T(n)
T( log n)
T(n log n) (page 40) repeat
23. One of the clever aspects of heaps is that they can be stored in arrays without
using any .
pointers (page 40) Repeat
constants
variables
functions
25. Sieve Technique applies to problems where we are interested in finding a single
item from a larger set of
n items (page 34)
phases
pointers
constant
26. A (an) is a left-complete binary tree that conforms to the
heap order
heap ref (page # 40)
binary tree
binary search tree
array
30. The analysis of Selection algorithm shows the total running time is
indeed in n,\
arithmetic
geometric
linear ref(page # 37)
orthogonal
One of the clever aspects of heaps is that they can be stored in arrays without
using any .
Select correct option:
pointers ref (page # 40)
constants
variables
The analysis of Selection algorithm shows the total running time is indeed
in n,
Select correct option:
arithmetic rep
geometric
linear
orthogonal
2.One of the clever aspects of heaps is that they can be stored in arrays without
using any .
pointers (page40)
constants
variables
functions
10.The analysis of Selection algorithm shows the total running time is indeed
in n,
arithmetic
geometric
linear (page37)
orthogonal
8.One of the clever aspects of heaps is that they can be stored in arrays
without using any .
Select correct option:
pointers (rep40)
constants
variables
functions
Sorting is one of the few problems where provable bonds exits
on how fast we can sort,
Select correct option:
upper
lower (page 39)
average
log n
T(nk) (page 34
T(n / 3)
n^2
n/3
linear
arithmetic
geometric (page 37)
exponent
One of the clever aspects of heaps is that they can be stored in arrays
without using any .
T(n) repeat
T(1 / 1 + n)
T(n / 2)
T((n / 2) + n)
The analysis of Selection algorithm shows the total running time is indeed
in n,
arithmetic
geometric
linear (page 39)
orthogonal