Searching Sorting and Hashing questions

Q33

GATE CS 2025 CS-1Searching Sorting and HashingNAT1 mark
The pseudocode of a function fun() is given below:
fun(int A[0,\dots,n-1]){
 for i=0 to n-2
 for j=0 to n-i-2
 if (A[j]>A[j+1])
 then swap A[j] and A[j+1]
}
Let A[0,…,29]A[0, \dots, 29] be an array storing 30 distinct integers in descending order. The number of swap operations that will be performed, if the function fun() is called with A[0,…,29]A[0, \dots, 29] as argument, is __________. (Answer in integer)
Show answer without attempting

Answer: 435

Q65

GATE CS 2025 CS-1Searching Sorting and HashingNAT2 marks
In a double hashing scheme, h1(k)=k mod 11h_1(k) = k \bmod 11 and h2(k)=1+(k mod 7)h_2(k) = 1 + (k \bmod 7) are the auxiliary hash functions. The size mm of the hash table is 11. The hash function for the i-th probe in the open address table is [h1(k)+i h2(k)] mod m[h_1(k) + i \, h_2(k)] \bmod m. The following keys are inserted in the given order: 63, 50, 25, 79, 67, 24.
The slot at which key 24 gets stored is ___________. (Answer in integer)
Show answer without attempting

Answer: 10 to 11

Q20

GATE CS 2025 CS-2Searching Sorting and HashingMCQ1 mark−1/3 if wrong
Consider an unordered list of NN distinct integers.

What is the minimum number of element comparisons required to find an integer in the list that is NOT the largest in the list?
Show answer without attempting

Answer: A

0/30 correct0 marks

Related topics in Algorithms