The GATE Grind

GATE Algorithms: Searching, Sorting and Hashing – Previous Year Questions

13 GATE previous year questions on Searching, Sorting and Hashing (Algorithms, Computer Science) with answers and explanations, from every paper.

  1. GATE 2017 CS Q58 (2 marks, Numerical answer) – Let A be an array of 31 numbers consisting of a sequence of 0's followed by a sequence of 1's. The problem is to find the smallest index i such that…
  2. GATE 2016 CS Q23 (1 mark, Multiple choice) – The worst case running times of Insertion sort, Merge sort and Quick sort, respectively, are:
  3. GATE 2015 CS Q14 (1 mark, Multiple choice) – Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting n ( 2) numbers? In the…
  4. GATE 2019 CS Q30 (1 mark, Numerical answer) – An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random. The probability that…
  5. GATE 2019 CS Q50 (2 marks, Multiple choice) – Consider the following statements: I. The smallest element in a max-heap is always at a leaf node II. The second largest element in a max-heap is…
  6. GATE 2026 CS (CS2) Q30 (1 mark, Numerical answer) – The keys 5, 28, 19, 15, 26, 33, 12, 17, and 10 are inserted into a hash table using the hash function h(k)=k 9. Collisions are resolved by chaining.…
  7. GATE 2026 CS (CS1) Q24 (1 mark, Multiple select) – Consider a hash table P[0, 1, , 10] that is initially empty. The hash table is maintained using open addressing with linear probing. The hash function…
  8. GATE 2025 CS (CS2) Q20 (1 mark, Multiple choice) – Consider an unordered list of N distinct integers. What is the minimum number of element comparisons required to find an integer in the list that is…
  9. GATE 2025 CS (CS2) Q41 (2 marks, Multiple choice) – An array A of length n with distinct elements is said to be bitonic if there is an index 1 i n such that A[1..i] is sorted in the non-decreasing order…
  10. GATE 2025 CS (CS1) Q33 (1 mark, Numerical answer) – The pseudocode of a function fun() is given below: Let A[0,...,29] be an array storing 30 distinct integers in descending order. The number of swap…
  11. GATE 2023 CS Q20 (1 mark, Multiple choice) – An algorithm has to store several keys generated by an adversary in a hash table. The adversary is malicious who tries to maximize the number of…
  12. GATE 2022 CS Q16 (1 mark, Multiple choice) – Suppose we are given n keys, m hash table slots, and two simple uniform hash functions h 1 and h 2. Further suppose our hashing scheme uses h 1 for…
  13. GATE 2021 CS Q19 (1 mark, Multiple choice) – Consider the following array: [23, 32, 45, 69, 72, 73, 89, 97]. Which algorithm out of the following options uses the least number of comparisons…