Skip to content

GATE CS Searching, Sorting, Hashing questions

Practise Searching, Sorting, Hashing questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ2006AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The median of nn elements can be found in O(n)O(n) time. Which one of the following is correct about the complexity of quick sort, in which median is selected as pivot?
Official PYQ2006AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Which one of the following in place sorting algorithms needs the minimum number of swaps?
Official PYQ2005AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Suppose there are ⌈log⁡n⌉\lceil \log n \rceil sorted lists of ⌊n/log⁡n⌋\lfloor n /\log n \rfloor elements each. The time complexity of producing a sorted list of all these elements is: (Hint:Use a heap data structure)
Official PYQ2004AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The tightest lower bound on the number of comparisons, in the worst case, for comparison-based sorting is of the order of
Official PYQ2003AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
In a permutation a1…ana_1\ldots a_n, of nn distinct integers, an inversion is a pair (ai,aj)(a_i, a_j) such that i<ji < j and ai>aj.a_i > a_j. What would be the worst case time complexity of the Insertion Sort algorithm, if the inputs are restricted to permutations of 1...n1. . . n with at most nn inversions?
Official PYQ2003AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
In a permutation a1...ana_1 ... a_n, of n distinct integers, an inversion is a pair (ai,aj)(a_i, a_j) such that i<ji < j and ai>aja_i > a_j. If all permutations are equally likely, what is the expected number of inversions in a randomly chosen permutation of 1...n1. . . n?
Official PYQ2003AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The usual Θ(n2)\Theta(n^2) implementation of Insertion Sort to sort an array uses linear search to identify the position where an element is to be inserted into the already sorted part of the array. If, instead, we use binary search to identify the position, the worst case running time will
Official PYQ2002AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Consider the following algorithm for searching for a given number xx in an unsorted array A[1..n]A[1..n] having nn distinct values: Choose an ii at random from 1..n1..n If A[i]=xA[i] = x, then Stop else Goto 1; Assuming that xx is present in AA, what is the expected number of comparisons made by the algorithm before it terminates?
Official PYQ2001AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using Randomized quicksort?
Official PYQ1999AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
If one uses straight two-way merge sort algorithm to sort the following elements in ascending order: 20, 47, 15, 8, 9, 4, 40, 30, 12, 1720, \ 47, \ 15, \ 8, \ 9, \ 4, \ 40, \ 30, \ 12, \ 17 then the order of these elements after second pass of the algorithm is:
Official PYQ1999AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
A sorting technique is called stable if
Official PYQ1998AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Give the correct matching for the following pairs: …
Official PYQ1996AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Quick-sort is run on two inputs shown below to sort in ascending order taking first element as pivot 1,2,3,…n1, 2, 3, \dots n n,n−1,n−2,…,2,1n, n-1, n-2, \dots, 2, 1 Let C1C_1 and C2C_2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then,
Official PYQ1996AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The average number of key comparisons required for a successful search for sequential search on nn items is
Official PYQ1995AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
For merging two sorted lists of sizes mm and nn into a sorted list of size m+nm+n, we require comparisons of
Official PYQ1995AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Merge sort uses:
Official PYQ1994AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Algorithm design technique used in quicksort algorithm is?
Official PYQ1992AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Following algorithm(s) can be used to sort nn in the range [1…n3][1\ldots n^3] in O(n)O(n) time
Official PYQ1991AlgorithmsSearching, Sorting, HashingNAT · 1 mark
The minimum number of comparisons required to sort 55 elements is ______
Official PYQ1990AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The complexity of comparison based sorting algorithms is: