CS502 Objective File For Mid Term
CS502 Objective File For Mid Term
4.What type of instructions Random Access Machine (RAM) can execute? Choose best
Algebraic and logic
Geometric and arithmetic
Arithmetic and logic(page#10)
Parallel and recursive
5.What will be the total number of max comparisons if we run brute-force maxima
algorithm with n elements.
*n 2
n
2
*n
*n
*n 8
Answe is option 3
10.When we call heapify then at each level the comparison performed takes time
It will take (1)
Time will vary according to the nature of input data
It can not be predicted
It will take (log n)
11.In Quick sort, we don’t have the control over the sizes of recursive calls
True(page#49)
False
Less information to decide
Either true or false
14. For Chain Matrix Multiplication we can not use divide and conquer approach because,
We do not know the optimum k (pg#86)
We use divide and conquer for sorting only
We can easily perform it in linear time
Size of data is not given
16.Suppose we have three items as shown in the following table, and suppose the
capacity of the knapsack is 50 i.e. W = 50.
The optimal solution is to pick
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
17 - What type of instructions Random Access Machine (RAM) can execute? Choose best
answer
1. Algebraic and logic
2. Geometric and arithmetic
3. Arithmetic and logic (rep)
4. Parallel and recursive
Correct Choice : 3 From Lectuer # 1
20 - What will be the total number of max comparisons if we run brute-force maxima?
algorithm with n elements?
1. n^2
2. n^n/2
3. n
4. n^8
Correct Choice : 1 From Lectuer # 3
21 - function is given like 4n^4+ 5n^3+n what is the run time of this
1. theata(n^4)
2. theata(n^3)
3. theata(4n^4+ 5n^3)
4. theata(4n^4+ 5n^3)
Correct Choice : 1 From Lectuer # 4
22 - 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?
1. 90 seconds
2. 9 seconds
3. 0.9 seconds
4. 0.09 seconds
Correct Choice : 2 From Lectuer # 4
23 - The appropriate big θ classification of the given function. f(n) = 4n2 + 97n + 1000 is
1. ?(n)
2. O(2^n)
3. O(n^2)
4. O(n^2logn)
Correct Choice : 3 From Lectuer # 4
27- - How much time merge sort takes for an array of numbers?
1. (n^2)
2. T(n)
3. T( log n)
4. T(n log n)
Correct Choice : 2 From Lectuer # 8
30 - Sieve Technique applies to problems where we are interested in finding a single item
from a larger set of _____________
1. n items (pg#34)
2. phases
34 - How many elements do we eliminate in each time for the Analysis of Selection
algorithm?
1. n / 2 elements
2. (n / 2) + n elements
3. n / 4 elements
4. n elements
Correct Choice : 4 From Lectuer # 10
35- Sieve Technique applies to problems where we are interested in finding a single item
from a larger set of _____________
1. n items
2. phases
3. pointers
4. constant
Correct Choice : 1 From Lectuer # 10
36 - The analysis of Selection algorithm shows the total running time is indeed ________in
n,
1. arithmetic
2. geometric
3. linear (pg#37)
4. orthogonal
Correct Choice : 3 From Lectuer # 10
39 - A (an) _________ is a left-complete binary tree that conforms to the heap order
1. heap (pg#40)
2. binary tree
3. binary search tree
. array
Correct Choice : 1 From Lectuer # 11
40 - For the heap sort, access to nodes involves simple _______________ operations.
1. arithmetic (pg#41)
2. binary
3. algebraic
4. logarithmic
Correct Choice : 1 From Lectuer # 11
41 - We do sorting to,
1. keep elements in random positions
2. keep the algorithm run in linear order
3. keep the algorithm run in (log n) order
4. keep elements in increasing or decreasing order (pg#39)
Correct Choice : 1 From Lectuer # 11
46 - One of the clever aspects of heaps is that they can be stored in arrays without using
any _______________.
1. pointers (pg#40)
2. constants
3. variables
4. functions
Correct Choice : 1 From Lectuer # 1
49 - When we call heapify then at each level the comparison performed takes time It will
take O (1)
1. Time will vary according to the nature of input data
2. It can not be predicted
3. It will take O (log n)
4. None of the Given
Correct Choice : 3 From Lecture # 12
50 - After partitioning array in Quick sort, pivot is placed in a position such that
1. Values smaller than pivot are on left and larger than pivot are on right (
2. Values larger than pivot are on left and smaller than pivot are on right
3. Pivot is the first element of array
4. Pivot is the last element of array
Correct Choice : 2 From Lectuer # 13
55 - In counting sort, once we know the ranks, we simply _________ numbers to their final positions in an
output array.
1Delete
2 copy
3 Mark
4 arrange
Correct Choice : 2 From Lectuer # 15
1.
56 - An in place sorting algorithm is one that uses ___ arrays for storage
1. Two dimensional arrays
2. More than one array
3. No Additional Array (pg#54)
4. None of the above
Correct Choice : 3 From Lectuer # 15
2.
57 - Continuation/counting sort is suitable to sort the elements in range 1 to k
1. K is Large
2. K is not known
3. K may be small or large
4. K is small (pg#57)
Correct Choice : 4 From Lectuer # 15
3.
58 - In stable sorting algorithm.
1. If duplicate elements remain in the same relative position after sorting
2. One array is used
3. More than one arrays are required
61- One of the clever aspects of heaps is that they can be stored in arrays without using
any _______________.
1. pointers (rep)
2. constants
3. variables
. functions
Correct Choice : 1 From Lecture # 15
62 - Quick sort is
1. Stable & in place
2. Not stable but in place (pg#54)
3. Stable but not in place
4. Some time stable & some times in place
63 - Quick sort is
1. Stable & in place
2. Not stable but in place (rep)
3. Stable but not in place
4. Some time stable & some times in place
Correct Choice : 2 From Lectuer # 15
69 - Memorization is?
1. To store previous results for future use
2. To avoid this unnecessary repetitions by writing down the results of recursive
calls and looking them up again if we need them later (pg#74)
3. To make the process accurate
4. None of the above
Correct Choice : 2 From Lectuer # 16
75 - If there are O (n^2) entries in edit distance matrix then the total running time is
1. O (1)
77 - For Chain Matrix Multiplication we can not use divide and conquer approach because,
1. We do not know the optimum k (rep)
2. We use divide and conquer for sorting only
3. We can easily perform it in linear time
4. Size of data is not given
Correct Choice : 1 From Lectuer # 19
80 The codeword assigned to characters by the Huffman algorithm have the property that
no codeword is the postfix of any other.
1. TRUE
2. FALSE
Correct Choice : 2 From Lectuer # 22
81 - The greedy part of the Huffman encoding algorithm is to first find two nodes with
larger frequency.
1. TRUE
2. FALSE
Correct Choice : 2 From Lectuer # 22
84-Heaps can be stored in arrays without using any pointers; this is due to the ____________ nature of
the binary tree,
left-complete
right-complete
tree nodes
tree leaves
87- A (an) _________ is a left-complete binary tree that conforms to the heap order
heap ( pg#40)
binary tree
binary search tree
array
True (rep)
False
16
10
32
31 (not sure)
91- 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,
Select correct option:
linear
arithmetic
geometric (pg37)
exponent
92- 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,
Select correct option:
linear
arithmetic
geometric (rep)
exponent
93-In inplace sorting algorithm is one that uses array for storage :
1. An additional array
2. No additional array (rep)
3. Both of the above
4. More then one array of one dimension.
94-The running time of quick sort depends heavily on the selection of.
1. No of inputs
2. Arrangement of element in array
3.Size Of element
4. Pivot element rep
98-A (an) _________ is a left-complete binary tree that conforms to the heap order
Heap rep
binary tree
binary search tree
array
99-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 rep
exponent
100-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 (pg#37)
n/2+n/4
102-The recurrence relation of Tower of Hanoi is given below T(n)={1 if n=1 and 2T(n-1) if n >1 In order
to move a tower of 5 rings from one peg to another, how many ring moves are required?
16
10
32
31
106-Quick sort is
1. Stable & in place
2. Not stable but in place (rep)
3. Stable but not in place
4. Some time stable & some times in place
116-The analysis of Selection algorithm shows the total running time is indeed ________in n,
arithmetic
geometric
linear pg#37
orthogonal
117-How many elements do we eliminate in each time for the Analysis of Selection algorithm?
n / 2 elements (pg#37)
(n / 2) + n elements
n / 4 elements
2 n elements
121-In selection algorithm, becausewe eliminate a constant fraction of the array with each phase, we get
the
Convergent geometric series rep
Divergent geometric series
None of these
123-If algorithm A has running time 7n2 + 2n + 3 and algorithm B has running time 2n2, then
Both have same asymptotic time complexity rep
A is asymptotically greater
B is asymptotically greater
None of others
Then T(5) is
25
75
79
130-The Sieve Sequence is a special case where the number of smaller subproblems is just____.
4
Many
1
Few
131-How many elements do we eliminate each time for the Analysis of Selection
Algorithm?
(n / 2)+n Elements
n / 2 Elements
n / 4 Elements
2 n Elements
132-We do sorting to?
Keep elements in random position
Keep the algorithm run in linear order
Keep Elements in Ascending or Descending Order rep
Keep the algorithm run in (log n) order
133-Sorting is one of the few problems where provable ____ bounds exit on how fast we can sort?
Upper
Average
Log n
Lower rep
134-In the analysis of Selction Algorithm, we eliminate the constant fraction of the array with each phase, we
get convergent _____ series in the analysis.
141-Due to left complete nature of binary tree, the heap can be stored in
• Arrays rep
• Structures
• Link Lis
• Stack
143-For Chain Matrix Multiplication we can not use divide and conquer approach
because,
We do not know the optimum k
We use divide and conquer for sorting only rep
We can easily perform it in linear time
Size of data is not given
145-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
True Page 35
False
147-A heap is a left-complete binary tree that conforms to the___________
increasing order only
decreasing order only
heap order Page 40
(log n) order
148-A (an) _________ is a left-complete binary tree that conforms to the heap order
Heap Page 40
binary tree
binary search tree
array
152-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
157-A (an) _________ is a left-complete binary tree that conforms to the heap order
Heap
binary tree
binary search tree
array
159-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
160- The sieve technique is a special case, where the number of sub problems is just
5
many
1 Page 34
few
162-The recurrence relation of Tower of Hanoi is given below T(n)={1 if n=1 and 2T(n-1) if n >1 In order
to move a tower of 5 rings from one peg to another, how many ring moves are required?
16
10
32
31
167-How many elements do we eliminate in each time for the Analysis of Selection algorithm?
n / 2 elements rep
(n / 2) + n elements
n / 4 elements
2 n elements
170-One of the clever aspects of heaps is that they can be stored in arrays without using
any_______________.
pointers rep
constants
variables
functions
173- 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 rep
exponent
175-. 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 rep
n/2+n/4
176-. In which order we can sort?
increasing order only
decreasing order only
increasing order or decreasing order rep
both at the same time
· T(n) Page 37
· T(1/1+n)
· T(n/2)
· T((n/2) +n)
182-How many elements do we eliminate each time for the Analysis of Selection Algorithm?
· (n / 2)+n Elements
· n / 2 Elements
· n / 4 Elements
184-The Sieve Sequence is a special case where the number of smaller sub problems is just_ .· 4
· Many
·1
· Few
185-Heaps can be stored in arrays without using any pointers this is due to the of the binary tree?
· Tree Nodes
· Right-Complete Nature
· Left-Complete Nature
· Tree Leaves
187-The Analysis of Selection Sort shows that the total running time is indeed in n?
· Geometric
· Linear
· Arithmetic
· Algebraic
192-How many elements do we eliminate each time for the Analysis of Selection Algorithm?
· (n / 2)+n Elements
· n / 2 Elements
· n / 4 Elements
· 2 n Elements
194-The Sieve Sequence is a special case where the number of small er sub problems is just_ .
·4
· Many
·1
· Few
195-Heaps can be stored in array s without using any pointers this is due to the of the binary tree?
· Tree Nodes
· Right-Complete Nature
· Left-Complete Nature
· Tree Leaves
The Analysis of Selection Sort shows that the total running time is indeed in n?
· Geometric
· Linear pg#37
· Arithmetic
· Algebraic
Go0d Luck
MIDTERM EXAMINATION
Fall 2011
CS502- Fundamentals of Algorithms
1
Question No: 1 ( Marks: 1 ) - Please choose one
word Algorithm comes from the name of the muslim author ____________
MIDTERM EXAMINATION
Spring 2010
CS502- Fundamentals of Algorithms
► notation
► notation
► Flowchart Click here for detail
► Asymptotic notation
► 256MB
► 512MB
► an infinitely large (Page 10)
► 100GB
2
Question No: 4 ( Marks: 1 ) - Please choose one
What type of instructions Random Access Machine (RAM) can execute? Choose best answer
3
Question No: 9 ( Marks: 1 ) - Please choose one
Consider the following Algorithm:
Factorial (n){
if (n=1)
return 1
else
return (n * Factorial(n-1))
}
Recurrence for the following algorithm is:
► 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
4
Question No: 14 ( Marks: 1 ) - Please choose one
For Chain Matrix Multiplication we can not use divide and conquer approach because,
► Items 1 and 2
► Items 1 and 3
► Items 2 and 3 (correct)
► None of these
5
MIDTERM EXAMINATION
Spring 2010
CS502- Fundamentals of Algorithms
6
Question No: 1 ( Marks: 1 ) - Please choose one
Counting sort the numbers to be sorted are in the range 1 to k where k is small.
►True (Page 57)
►False
MIDTERM EXAMINATION
Spring 2007
CS502- Fundamentals of Algorithms
►O(n)
►O( n log2 n)
►O(3)
►O( log2 ( log2 n ))
►O ( log2 n)
7
Question No: 1 ( Marks: 1 ) - Please choose one
In selection algorithm, because we eliminate a constant fraction of the array with each phase, we get the
►Link list
►Structure
►Array (Page 40)
►None of above
Infinite
Continuous
Constant (Page 10)
Variable
True
False (Page 28)
8
Question No: 1 ( Marks: 1 ) - Please choose one
In analysis, the Upper Bound means the function grows asymptotically no faster than its largest term.
True
False
True
False (Page 27) [Divide and Conquer]
Member
Minimal
Maximal (Page 11)
Joint
9
Question No: 1 ( Marks: 1 ) - Please choose one
The running time of an algorithm would not depend upon the optimization by the compiler but that of an
implementation of the algorithm would depend on it.
Results
Variables
Size
Growth rates (Page 23)
10
Question No: 1 (Marks: 1) - Please choose one
Asymptotic growth rate of the function is taken over_________ case running time.
Select correct option:
Best
Average
Worst (Page 14)
Normal
n
2n
n+1
n2 (Page 23)
Macro
Micro
Both Macro & Micro (Page 8)
Normal
True
False (Page 18)
11
nT(n-1)+1
2T(n-1)+1
T(n-1)+cn
T(n-1)+1
Memory
Running Time
Memory and Running Time (Page 9)
Energy
Two
Lower
Upper (Page 25)
Both lower & upper
1
2 (Page 16)
3
4
12
Question No: 1 ( Marks: 1 ) - Please choose one
Brute-force algorithm for 2D-Maxima is operated by comparing ________ pairs of points.
Two
Some
Most
All (Page 18)
Normal
Least (Page 23)
Most
All
One
Lower
Upper
Both lower & upper (Page 25) rep
Array
Queue
Stack (Page 18)
Tree
13
Quiz No.1 (2012)
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
The number of nodes in a complete binary tree of height h is
arithmetic
geometric
linear (Page 37)
orthogonal
14
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
A heap is a left-complete binary tree that conforms to the ___________
pivot
Sieve
smaller sub problems (Page 34)
Selection
15
CS502 - Fundamentals of Algorithms
Quiz No.1 12-11-2012
linear
arithmetic
geometric (Page 37)
exponent
16
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
For the heap sort, access to nodes involves simple _______________ operations.
(n / 2)+n elements
(n / 2) elements (Page 37)
n / 4 elements
2 n elements
17
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
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)
18
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
Quick sort is
Merger Sort
Quick Sort (Page 54)
Continuation Sort
Bubble Sort
If duplicate elements remain in the same relative position after sorting (Page 54)
One array is used
More than one arrays are required
Duplicating elements not handled
19
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
Sieve Technique applies to problems where we are interested in finding a single item from a larger set of
_____________
upper
lower (Page 39)
average
log n
No of inputs
Arrangement of elements in array
Size o elements
Pivot elements (Page 49)
Bubble sort
Insertion sort
Both of above (Page 54)
20
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
One Example of in place but not stable sort is
Large
Medium
Small Click here for detail
Not Known
21
CS501 - Quiz No.2 (Spring 2013)
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
A point p in 2-dimensional space is usually given by its integer coordinate(s)____________
p.x only
p.y only
p.x & p.z
p.x & p.y (Page 10)
Less than
Equal to or Less than (Page 25)
Equal or Greater than
Greater than
True
False (Page 10)
22
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
_________ is one of the few problems, where provable lower bounds exist on how fast we can sort.
Searching
Sorting (Page )
Both Searching & Sorting
Graphing
Very easy
Usually considered difficult (Page 31)
True
False (Page 7)
23
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
While Sorting, the ordered domain means for any two input elements x and y _________ satisfies only.
x<y
x>y
x=y
All of the above (Page 39)
True (Page 9)
False
True
False (Page 34)
In increasing order
In decreasing order
According to Pivot (Page 35)
Randomly
24
Question No: 1 of 10 ( Marks: 1 ) - Please choose one
In pseudo code, the level of details depends on intended audience of the algorithm.
Small
Large
Equal (Page 28)
Not Equal
25
CS502 – Design & Analysis of Algorithms Midterm
2013
1. The word Algorithm comes from the name of the Muslim author _______________
Abu Ja’far Mohammad ibn Musaal-Khowarizmi or Al-Khwarizmi
Khwarizm
Kheva
Uzbekistan
2. In order to say anything meaningful about our algorithms, it will be important for us to
settle on a ___________.
C++ program
Java program
Pseudo program
Mathematical model of computation pg 10
3. A RAM is an idealized machine with ______________ random-access memory.
256MB
512MB
an infinitely large pg 10
100GB
4. Which formula is used for calculating worst case running time?
Tworst (n) = max |I |= n T ( I )
1 Tworst ( n ) = max |I | =1 T ( n )
Tworst (n) = max |I |= n T (n)
Q # 01: In order to say anything meaningful about our algorithms, it will be important for
us to settle on a ___________.
C++ program
Java program
Pseudo program
Mathematical model of computation
Q # 04: For the heap sort, access to nodes involves simple _______________ operations.
Arithmetic 41
binary
algebraic
logarithmic
Q # 05: If a sorting algorithm solely based on comparisons of keys in the array then it is
impossible to sort more efficiently than
Ω (n lg n)
Θ (n lg n)
Ο (n lg n)
None of these
Q # 06: The comparison based algorithm defines a(n) __________.
decision tree 54
array
linked list
stack
{( 7,13) , (12,12 ) , (14,10 ) , (15, 7 )} 20
{( 7, 7 ) , ( 7,13) , ( 9,10 ) , (11,5) , (14,10 )}
{( 2,5) , ( 4, 4 ) , ( 4,11) , ( 5,1) , (14,10 )}
{( 4, 4 ) , ( 4,11) , ( 7,13) , ( 9,10 )(14,10 )}
n
∑n
i =1
Q # 19:
What is the running time of the above sorting algorithm in worst case?
Θ ( n2 )
39
Θ ( n3 )
Θ ( n log n )
Θ ( log n )
Q # 20: The reason for introducing Sieve Technique algorithm is that it illustrates a very
important special case of_____________
Divide-and-conquer 34
Decrease and conquer
6
Greedy nature
2-dimension Maxima
MIDTERM EXAMINATION
What is common between Bubble sort, Insertion sort, Selection sort, Quick sort, and Heap
sort?
All are in-place algorithms (pg54)
All are stable algorithms
None of these
All are unstable algorithms
In order to say anything meaningful about our algorithms, it will be important for us to
settle on a ___________.
C++ program
Java program
Pseudo program
Mathematical model of computation (pg10)
Q # 04: In which order we can sort?
increasing order or decreasing order 39
both at the same time
increasing order only
decreasing order only
Q # 05: For the heap sort we store the tree nodes in
level-order traversal 40
in-order traversal
pre-order traversal
post-order traversal
Q # 06: Quick sort procedure was invented by
Hoare in 1960
Sedgewick
Mellroy
Coreman
Q # 07: For sorting algorithms which one is the efficient algorithm having running time?
O(n2)
O(n log n) not sure
O(n2 log n)
O(n3)
Q # 08: When a recursive algorithm revisits the same problem over and over again, we say
7 that the optimization problem has _______________ sub-problems.
Overlapping
Over costing
Optimized
None of these
Θ ( n6 )
2n
Θ n 6
Θ ( n2 )
14 page
8 Θ ( 2n lg 6 )
Q # 14: Due to left-complete nature of binary tree, heaps can be stored in
Arrays 40
Structures
15
18