Paper 1
Paper 1
1. o(g(n))∩ω(g(n)) is:
A) o(g(n)).
B) ω(g(n)).
C) null set.
D) none of them.
3. There are n numbers of students in a class. We want to find the student who got third
highest marks in the class. Which sorting technique would be best?
A) Insertion Sort.
B) Quick sort.
C) Bubble Sort.
D) Heap Sort.
9. An Advantages of chained hash table over the open addressing scheme is:
A) worst case complexity of search operation is less.
B) Space used is less.
C) Deletion is easier.
D) None of the above.
11. Consider an array A[1..n]. It consists of a permutation of numbers 1..n. Now compute
another array B[1..n] as follows: B[A[i]]:=I for all i. which of the following is true?
A) B will be a sorted array.
B) B is a permutation of array A.
C) Doing the same transformation twice will not give the same array.
D) B is not a permutation of A.
E) None of the above.
12. Consider the class of recursive and iterative programs. Which of the following is
false?
A) Recursive program are more powerful then iterative program.
B) For every iterative program there is an equivalent recursive program.
C) Recursive program require dynamic memory management.
D) Recursive program do not terminates sometimes.
E) Iterative program and recursive program are equally expressive.
13. The first n cells of an array L contains positive integers sorted in decreasing order,
and the remaining m-n cells all contain 0. Then, given an integer x, in how many
comparisons can one find the position of x in L.
A) At least n comparisons are necessary in worst case.
B) At least log m comparisons are necessary in worst case.
C) O(log(m-n)) comparisons suffice.
D) O(log n) comparisons suffice.
E) O(log(m/n)) comparisons suffice.
14. Suppose you are given n numbers and you sort them in descending order as follow:
First find the maximum. Remove this element from the list and find the maximum of
remaining elements. Remove this element and so on, until all the elements exhausted.
How many comparisons does this method require in worst case?
A) O(n²).
B) O(n logn).
C) Same as heap sort.
D) O(n).
15. Suppose you are given an array A with 2n numbers. The numbers in odd positions are
sorted in ascending order, that is, A[1]≤A[3] ≤……A[2n-1]. The number at even
positions are sorted in descending order, that is, A[2]≥A[4]……. ≥A[2n].what method
you would recommended for determining if a given number is in the array?
A) Sort the array using quick sort and the perform binary search.
B) Merge sorted lists and perform binary search.
C) Perform a single binary search.
D) Perform a separate binary searches on the odd positions and even positions.
E) Perform a sequentially from the end of the array.
16. Consider sorting n number stored in array A by first finding the smallest element of A
and exchanging it with the element in A[1]. Then find the second smallest element of A
and exchange it with A[2]. Continue in this manner for the first n-1 elements of A. what
will be the time complexity?
E) O(n²).
F) O(n logn).
G) O(n² logn).
H) O(n).
17. To solve factorial of a number we have designed an recursive approach given below:
Recursion(int x)
{
If(x≤1)
{
Return 1;
}
Else
{
F=x*---------
Return f;
}
}
One statement in this program is missing. Select best appropriate among the options:
A) recursion(x*x)
B) recursion(x)
C) recursion(x-1)
D) recursion(x+1)
A) O(n logn).
B) O(n).
C) O(logn).
D) O(n²).
20. Let f(n),g(n) and h(n) be the functions defined for positive integers such that:
F(n)=O(g(n)),g(n)≠O(f(n)),g(n)=O(h(n)) and h(n)=O(g(n)).which of the following
statement is false?
A) f(n)+g(n)=O(h(n))+h(n)
B) h(n) ≠ O(f(n))
C) f(n)h(n) ≠O(g(n))h(n)
D) None