Question 1
Let F(n) denote the maximum number of comparisons made while searching for an entry in a sorted array of size 𝑛 using binary search. Which ONE of the following options is TRUE?
F(n)=F(⌊n/2⌋)+1
F(n)=F(⌊n/2⌋)+F(⌈n/2⌉)
F(n)=F(⌊n/2⌋)
F(n)=F(n-1)+1
Question 2
Consider the following python code:
def count(child_dict, i):
if i not in child_dict.keys():
return 1
ans = 1
for j in child_dict[i]:
ans += count(child_dict, j)
return ans
child_dict = dict()
child_dict[0] = [1,2]
child_dict[1] = [3,4,5]
child_dict[2] = [6,7,8]
print(count(child_dict,0))
Which ONE of the following is the output of this code?
6
1
8
9
Question 3
Consider the following Python function:1
def fun(D, s1, s2):
if s1 < s2:
D[s1], D[s2] = D[s2], D[s1]
fun(D, s1+1, s2-
What does this Python function fun() do? Select the ONE appropriate option below.
It finds the smallest element in D from index s1 to s2, both inclusive.
It performs a merge sort in-place on this list D between indices s1 and s2, both inclusive.
It reverses the list D between indices s1 and s2, both inclusive
It swaps the elements in D at indices s1 and s2, and leaves the remaining elements unchanged.
Question 4
Match the items in Column 1 with the items in Column 2 in the following tab
| Column 1 | Column 2 |
| p. First In First Out q. Lookup Operation r. Last In First Out | i. Stacks ii. Queues iii. Hash Tables |
(p) − (ii), (q) − (iii), (r) − (i)
(p) − (ii), (q) − (i), (r) − (iii)
(p) − (i), (q) − (ii), (r) − (iii)
(p) − (i), (q) − (iii), (r) − (ii)
Question 5
Consider the following tree traversals on a full binary tree:
1.PreOrder
2.Inorder
3.PostOrder
Which of the following traversal options is/are suffiecient to uniquely reconstruct the full Binary Tree?
(i) and (ii)
(ii) and (iii)
(i) and (iii)
(ii) only
Question 6
Consider sorting the following array of integers in ascending order using an in-place Quicksort algorithm that uses the last element as the pivot.
| 60 | 70 | 80 | 90 | 100 |
The minimum number of swaps perfoemed during this quicksort ?
0
1
2
4
Question 7
Consider the following sorting algorithms:
(i) Bubble sort
(ii) Insertion sort
(iii) Selection sort
Which ONE among the following choices of sorting algorithms sorts the numbers in the array [4, 3, 2, 1, 5] in increasing order after exactly two passes over the array?
(i) only
(iii) only
(i) and (iii) only
(ii) and (iii) only
Question 8
Consider the directed acyclic graph (DAG) below:

Which of the following is/are valid vertex orderings that can be obtained from a topological sort of the DAG?
P Q R S T U V
P R Q V S U T
P Q R S V U T
P R Q S V T U
Question 9
Let H,𝐼, 𝐿, and 𝑁 represent height, number of internal nodes, number of leaf nodes, and the total number of nodes respectively in a rooted binary tree. Which of the following statements is/are always TRUE?
𝐿 ≤ 𝐼 + 1
𝐻 + 1 ≤ 𝑁 ≤ 2 𝐻+1 − 1
𝐻 ≤ 𝐼 ≤ 2 𝐻 − 1
𝐻 ≤ 𝐿 ≤ 2 𝐻−1
Question 10
Consider performing uniform hashing on an open address hash table with load factor [Tex]\alpha = \frac{n}{m} < 1[/Tex], where 𝑛 elements are stored in the table with m slots. The expected number of probes in an unsuccessful search is at most [Tex]\frac{1}{1-\alpha}[/Tex]. Inserting an element in this hash table requires at most ______ probes, on average.
[Tex]n\frac{1}{1-\alpha}[/Tex]
[Tex]\frac{1}{1-\alpha}[/Tex]
[Tex]1+\frac{\alpha}{2}[/Tex]
[Tex]\frac{1}{1+\alpha}[/Tex]
There are 20 questions to complete.