"Exploring the Essential Functions and Design Considerations of Spillways in ...
Ee693 sept2014quiz1
1. EE693 DATA STRUCTURES AND ALGORITHMS
QUIZ-1 EXAMINATION
16 SEPTEMBER, 2014, Time: 1 Hours
EEE Department, IIT Guwahati
NOTE: Attempt and solve all the questions. Question-1 to Question-20 are multiple choice questions (more than one
choices may be correct). Question-1 to Question-20, marks will be awarded, if and only if, all the correct
choice(s) will be made. 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. Please tick the correct choice(s). All the questions are of 0.5
mark.
Name: Roll No:
1. This is the welcome question! All the best for EE693 Quiz-1.
There are 25 horses. At most, 5 horses can race together at a time. You must determine the fastest, second fastest,
and third fastest horses. The minimum number of races in which this can be done is
(a) 8 (b) 9 (c) 6 (d) 7
2. Given functions
f1(n) =
log n!
n
, f2(n) =
log n
log log n
,
f3(n) =
log (⌈log n⌉!)
log n
, f4(n) = log log n,
which among the following is correct?
(a) O(f2) ≤ O(f1) ≤ O(f3) ≤ O(f4)
(b) O(f3) ≤ O(f4) ≤ O(f2) ≤ O(f1)
(c) O(f4) ≤ O(f3) ≤ O(f2) ≤ O(f1)
(d) O(f2) ≤ O(f1) ≤ O(f4) ≤ O(f3)
3. Given two arrays, each containing n numbers already in sorted order, the time complexity of the fastest algorithm to
compute the median of all 2n elements is
(a) O(1) (b) O(n) (c) O(
√
n) (d) O(log n)
4. Which of the following sorting algorithms is not stable ?
(a) Merge Sort (b) Quick Sort (c) Counting Sort (d) Radix Sort
5. Solution to the recurrence T(n) = T(1
3
n) + T(2
3
n) + cn is
(a) Ω(n) (b) Ω(n2
) (c) Ω(n3
) (d) Ω(nlog n)
6. Solution to the recurrence T(n) = max0≤q≤n−1(T(q) + T(n − q − 1)) + cn is
(a) Ω(n2
) (b) Ω(nlog2
n) (c) Ω(nlog n) (d) Ω(n)
7. Suppose you flip a fair coin n times. The expected length of the longest streak of consecutive heads is
(a) Θ(n) (b) Θ(1) (c) Θ(log n) (d) Θ(
√
n)
8. What is the least number of comparisons required to find the maximum and minimum of a list of n numbers?
(a) n + ⌈log n⌉ − 2 (b) 3⌊n
2
⌋ (c) 2n − 3 (d) n + ⌊
√
n⌋ − 2
9. Find the worst inputs for Insertion Sort among the following:
(a) A =< 3,5,1,6,2,4 >
(b) A =< 6,4,5,3,1,2 >
(c) A =< 3,1,4,5,6,2 >
(d) A =< 6,4,2,5,3,1 >
2. 10. Find the worst inputs for Merge Sort among the following:
(a) A =< 3,5,1,6,2,4 >
(b) A =< 6,4,5,3,1,2 >
(c) A =< 3,1,4,5,6,2 >
(d) A =< 6,4,2,5,3,1 >
11. Which of the following points is/are true about Linked List data structure when it is compared with array
(a) Arrays have better cache locality that can make them better in terms of performance.
(b) It is easy to insert and delete elements in Linked List.
(c) Random access is not allowed in a typical implementation of Linked Lists.
(d) The size of array has to be pre-decided, linked lists can change their size any time.
12. Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
(a) Insertion Sort (b) Quick Sort (c) Heap Sort (d) Merge Sort
13. In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is
(a) log2n (b) n
2
(c) log2n − 1 (d) n
14. A circularly linked list is used to represent a Queue. A single variable p is used to access the Queue. To which node
should p point such that both the operations enQueue and deQueue can be performed in constant time?
(a) rear node (b) front node (c) not possible with a single pointer (d) node next to front
15. Let S be a stack of size n >= 1. Starting with the empty stack, suppose we push the first n natural numbers in
sequence, and then perform n pop operations. Assume that Push and Pop operation take X seconds each, and Y
seconds elapse between the end of one such stack operation and the start of the next operation. For m >= 1, define
the stack-life of m as the time elapsed from the end of Push(m) to the start of the pop operation that removes m
from S. The average stack-life of an element of this stack is
(a) n(X+Y) (b) 3Y+2X (c) n(X+Y)-X (d) Y+2X
16. A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the
array. Variables top1 and top2 (topl<top2) point to the location of the topmost element in each of the stacks. If the
space is to be used efficiently, the condition for "stack full" is
(a) (top1 = MAXSIZE/2) and (top2 = MAXSIZE/2 + 1)
(b) top1 + top2 = MAXSIZE
(c) (top1 = MAXSIZE/2) or (top2 = MAXSIZE)
(d) top1 = top2 − 1
17. How many queues are needed to implement a stack. Consider the situation where no other data structure like arrays,
linked list is available to you.
(a) 1 (b) 2 (c) 3 (d) 4
18. Which of the following operations is not O(1) for an array of sorted data. You may assume that array elements are
distinct.
(a) Find the ith largest element
(b) Delete an element
(c) Find the ith smallest element
(d) All of the above
19. The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted
array of n integers is
(a) θ(n) (b) θ(logn) (c) θ(logn2
) (d) θ(n2
)
20. A program P reads in 500 integers in the range (0..100) representing the scores of 500 students. It then prints the
frequency of each score above 50. What would be the best way for P to store the frequencies?
(a) An array of 50 numbers
(b) An array of 100 numbers
(c) An array of 500 numbers
(d) A dynamically allocated array of 550 numbers
All the best for your mid-semester examinations.