(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
Ee693 sept2014quizgt2
1. EE693 DATA STRUCTURES AND ALGORITHMS
QUIZ-GT-2 EXAMINATION
25 OCTOBER, 2014, Time: 1 Hours
EEE Department, IIT Guwahati
NOTE: Attempt and solve all the questions. Question-1 to Question-16 are fill in the blank questions. Use of any kind
of electronic media other than calculators are strictly prohibited. If anybody finds voiding this rule will be
penalized with -10 marks penalty. Please do not forget to mention your Name and Roll No in the paper sheet.
All the questions are of 2 marks. Question 16 is for 2 Bonus Marks. You should attempt it after solving
all the other problems (Questions 1-15).
Name: Roll No:
1. This is the welcome question! All the best for EE693 Quiz-2 (GT).
Let A be a square matrix of size n x n. Consider the following program. The expected output is ⋯⋯
C = 100
for i = 1 to n do
for j = 1 to n do
{
Temp = A[i][j] + C
A[i][j] = A[j][i]
A[j][i] = Temp - C
}
for i = 1 to n do
for j = 1 to n do
Output(A[i][j]);
2. The minimum number of arithmetic operations required to evaluate the polynomial P(X) = X5
+ 4X3
+ 6X + 5 for a
given value of X using only one temporary variable are ⋯⋯.
3. You have an array of n elements. Suppose you implement quicksort by always choosing the central element of the
array as the pivot. In that case, the tightest upper bound for the worst case performance is ⋯⋯
4. The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is ⋯⋯
5. Consider two strings A = qpqrr and B = pqprqrp. Let x be the length of the longest common subsequence (not
necessarily contiguous) between A and B and let y be the number of such longest common subsequences between A
and B. Then x + 10y = ⋯⋯⋯
6. Suppose P,Q,R,S,T are sorted sequences having lengths 20,24,30,35,50 respectively. They are to be merged into a
single sequence by merging together two sequences at a time. The number of comparisons that will be needed in the
worst case by the optimal algorithm for doing this is ⋯⋯⋯
7. Consider the following pseudo code. The total number of multiplications to be performed is ⋯⋯⋯
D = 2
for i = 1 to n do
for j = i to n do
for k = j + 1 to n do
D = D * 3
8. Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions are resolved by chaining. The
following 9 keys are inserted in the order: 5,28,19,15,20,33,12,17,10. The maximum, minimum, and average chain
lengths in the hash table, respectively, are ⋯⋯⋯
9. A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is:
10,8,5,3,2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap
after the insertion of the elements is ⋯⋯⋯
2. 10. Consider a rooted Binary tree represented using pointers. The best upper bound on the time required to determine
the number of subtrees having having exactly 4 nodes O(na
Log(nb
)). Then the value of a + 10b is ⋯⋯⋯
11. Let P be a QuickSort Program to sort numbers in ascending order using the first element as pivot. Let t1 and t2
be the number of comparisons made by P for the inputs {1,2,3,4,5} and {4,1,5,3,2} respectively. The relationship
between t1 and t2 is ⋯⋯⋯
12. Consider the following C function in which size is the number of elements in the array E. The value returned by the
function MyX is ⋯⋯⋯
int MyX(int *E, unsigned int size)
{
int Y = 0;
int Z;
int i, j, k;
for (i = 0; i < size; i++)
Y = Y + E[i];
for (i = 0; i < size; i++)
for (j = i; j < size; j++)
{
Z = 0;
for (k = i; k <= j; k++)
Z = Z + E[k];
if (Z > Y)
Y = Z;
}
return Y;
}
13. The maximum height of any AVL-tree with 7 nodes is ⋯⋯⋯. Assume that the height of a tree with a single node is
0.
14. The worst case possible height of AVL tree is ⋯⋯⋯
15. The worst case possible height of Red-Black tree is ⋯⋯⋯
16. (Bonus Question) A program takes as input a balanced binary search tree with n leaf nodes and computes the value
of a function g(x) for each node x. If the cost of computing g(x) is min{no. of leaf-nodes in left-subtree of x, no. of
leaf-nodes in right-subtree of x} then the worst-case time complexity of the program is ⋯⋯⋯
All the best for next week quiz.