Consider the following array A[ ] with 10 elements

A[ 18, 4, 38, 19, 12, 15, 22, 55, 100 , 200 ]

Find the total number of inversions possible for the given array.

[ Hint: Inversion formal definition is two elements A[i] and A[j] form an inversion if A[i] > A[j] and i < j ]

9
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.00
Find the most appropriate matching for the below pairs

X

Y

P: Selection sort

1: Ω(n)

Q: Insertion sort

2: ϴ(d(n+k))

R: Merge Sort

3: O(n^2)

S: Radix sort

4: O(nlogn)

P-3, Q-1, R-4, S-2
P-1, Q-3, R-2, S-4
P-3, Q-1, R-2, S-4
P-1, Q-3, R-4, S-2
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
For the given nodes:

5, 6, 9, 15, 13, 12, 11

Minimum ____ number of interchanges are needed to convert it into a max-heap?

4
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.00
Consider a hash table with 7 slots. The hash function is h(k) = k mod 7. The collisions are resolved by chaining. The following 7 keys are inserted in the order:

15, 20, 25, 30, 35, 40, 45

The maximum chain length in the hash table is____?

1
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.00
Consider a hash table of size seven, with starting index zero, and a hash function (10x+3) mod 7. Assuming the hash table is initially empty and the sequence of filling elements are 14, 12, 18, 31, 20, 22, 2 is inserted into the table. What location would the key value 2 be inserted?
2
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.00
Consider double hashing of the form

h(k,i)=(h​1(k)+ih2(k)) mod m

Where h​1(k)=k mod m

h​2(k)=1+(k mod n)

Where n=m-2 and m=501 for k=15150,

What is the difference between first and second probes in terms of slots?

[ Note: i >= 1 ]

181
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
What will be the best and worst case time complexity of the below algorithm?


void function(int arr[ ], int n)

{

int i, key, j;

for (i = 1; i < n; i++)

{

key = arr[i];

j = i-1;

while (j >= 0 && arr[j] > key)

{

arr[j+1] = arr[j];

j = j-1;

}

arr[j+1] = key;

}

}

Best case: O(logn) and Worst case: O(n^3)
Best case: O(n) and Worst case: O(n^2)
Best case: O(n^2) and Worst case: O(n^2)
Best case: O(logn) and Worst case: O(n^2)
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
An array contains four occurrences of 50, three occurrences of 25 and five occurrences of 100 in any order. The array is to be sorted using swap operations(elements that are swapped need to be adjacent). What is the minimum number of swaps needed to sort an array in the worst case____?
47
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
Suppose we constructed the binary search tree as shown below. It starting with an

empty tree and inserting one element at a time from an input sequence, without any rotations or other manipulations. Which of the following assertions about the order of elements in the input sequence cannot be true?

18 came after 13 and 29 came before 39.
17 came before 18 and 33 came after 47.
11 came after 22 and 39 came before 52
13 came before 24 and 26 came before 38.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Which of the following statements is/are TRUE?

P: If we randomly choose a pivot elements each time, quicksort will always terminate in time O(n logn)

Q: Bubble and Merge sort is an example of stable property.

R: The collision resolution techniques by chaining and open addressing may result in the worst case search time for one of the ‘n’ keys in the hash table is O(n).

Only P
Q and R
P and R
P, Q and R
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Choose the correct option for following two statements

P: Consider an array containing n elements and divided into k (>=2) parts, each of size n-a. Where ‘a’ is a small integer and k is a constant. The computation cost of this operation (i.e dividing into parts) is a unit time. Find the recurrence relation for the given problem?

Q: Consider an array ‘A’ containing n distinct elements and those elements are in non decreasing order. What is the time complexity to find the element in which A[i] = i using divide-and-conquer approach?

P: T(n) = (n-a) * T(n/k) + 1 and Q: O(n^2)
P: T(n) = k * T(n-a) + 1 and Q: O(log n)
P: T(n) = k T(n/n-a) + a and Q: O(n log n)
P: T(n) = (n-a) T(n-a) + 1 and Q: O(n)
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider an array ‘A’ with 2i elements. The elements in odd position are sorted in non-increasing order that is A[1] >= A[3] >= A[5]......A[2i-1] The elements in even position are sorted in non-decreasing order, that is A[2]<= A[4] <= A[6].....A[2i].

What is the correct method recommended for finding if a given number is in an array?

Sort the given array using quick sort and then apply binary search on the array.
Merge the sorted lists and apply binary search.
Apply binary search on the entire array.
Separately apply binary search on the odd position elements and even position elements
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
You are given a sequence of n elements to sort. The input sequence consists of n/k subsequences,each containing k elements. The elements in a given subsequence are all smaller than the elements in the succeeding subsequence and larger than the elements in the preceding subsequence. Thus, all that is needed to sort the whole sequence of length n is to sort the k elements in each of the n/k subsequences. The lower bound on the number of comparisons needed to solve this variant of the sorting problem is_____?
Ω (n)
Ω (n/k)
Ω (nlogk )
Ω (n/klogn/k)
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
P: In a heap of depth d, there must be at least 2^d elements. (Assume the depth of the first element (or root) is zero).

Q: We can always find the maximum in a min-heap in O(log n) time

R: Given two heaps with n elements each, it is possible to construct a single heap comprising all 2n elements in O(n) time

S: Building a heap with n elements can always be done in O(n) time.

P-TRUE, Q-FALSE, R-TRUE and S-TRUE
P-FALSE, Q-TRUE, R-FALSE and S-FALSE
P-TRUE, Q-TRUE, R-FALSE and S-FALSE
P-FALSE, Q-FALSE, R-TRUE and S-TRUE
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Which of the following statements is/are True?

I. Heapsort can be used as the auxiliary sorting routine in radix sort, because it operates in place.

II. Consider a heap ‘H’. Each key in a heap is randomly increased or decreased by 1. Then we can restore the heap property on H in linear time O(n). The random choices are independent.

III. A major disadvantage of merge sort is that it cannot easily be converted into a stable sort.

I and II
II and III
Only II
I, II and III
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66