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 PYQ2019AlgorithmsSearching, Sorting, HashingNAT · 1 mark
An array of 2525 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random. The probability that the pivot element gets placed in the worst possible location in the first round of partitioning (rounded off to 22 decimal places) is ________
Official PYQ2017AlgorithmsSearching, Sorting, HashingNAT · 1 mark
Let AA be an array of 3131 numbers consisting of a sequence of 00's followed by a sequence of 11's. The problem is to find the smallest index ii such that A[i]A\left [i \right ] is 11 by probing the minimum number of locations in AA. The worst case number of probes performed by an optimal algorithm is ____________.
Official PYQ2016AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The worst case running times of Insertion sort , Merge sort and Quick sort, respectively are:
Official PYQ2016AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in the ascending order, which of the following are TRUE? Quicksort runs in Θ(n2)\Theta (n^2) time Bubblesort runs in Θ(n2)\Theta (n^2) time Mergesort runs in Θ(n)\Theta (n) time Insertion sort runs in Θ(n)\Theta (n) time
Official PYQ2015AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Which one of the following is the recurrence equation for the worst case time complexity of the quick sort algorithm for sorting n  (≥2)n\;( \geq 2) numbers? In the recurrence equations given in the options below, cc is a constant.
Official PYQ2015AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Suppose you are provided with the following function declaration in the C programming language. int partition(int a[], int n); The function treats the first element of a[ ]a[\:] as a pivot and rearranges the array so that all elements less than or equal to the pivot is in the left part of the array, and all elements greater than the pivot is in the right …
Official PYQ2015AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Assume that a mergesort algorithm in the worst case takes 3030 seconds for an input of size 6464. Which of the following most closely approximates the maximum input size of a problem that can be solved in 66 minutes?
Official PYQ2014AlgorithmsSearching, Sorting, HashingNAT · 1 mark
The minimum number of comparisons required to find the minimum and the maximum of 100100 numbers is ________
Official PYQ2014AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Let PP be quicksort program to sort numbers in ascending order using the first element as the pivot. Let t1t_1 and t2t_2 be the number of comparisons made by P for the inputs [1 2 3 4 5][1 \ 2 \ 3 \ 4 \ 5] and [4 1 5 3 2][4 \ 1 \ 5 \ 3 \ 2] respectively. Which one of the following holds?
Official PYQ2014AlgorithmsSearching, Sorting, HashingNAT · 1 mark
Suppose P,Q,R,S,TP, Q, R, S, T are sorted sequences having lengths 20,24,30,35,5020, 24, 30, 35, 50 respectively. They are to be merged into a single sequence by merging together two sequences at a time. The number of comparisons that will be needed in the worst case by the optimal algorithm for doing this is ____.
Official PYQ2014AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
You have an array of nn elements. Suppose you implement quicksort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is
Official PYQ2013AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The number of elements that can be sorted in Θ(log⁡n)\Theta(\log n) time using heap sort is
Official PYQ2013AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Which one of the following is the tightest upper bound that represents the number of swaps required to sort nn numbers using selection sort?
Official PYQ2012AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
A list of nn strings, each of length nn, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is
Official PYQ2009AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
In quick-sort, for sorting nn elements, the (n/4)th\left(n/4\right)^{th} smallest element is selected as pivot using an O(n)O(n) time algorithm. What is the worst case time complexity of the quick sort?
Official PYQ2009AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
What is the number of swaps required to sort nn elements using selection sort, in the worst case?
Official PYQ2008AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Consider the following C program that attempts to locate an element xx in an array Y[ ]Y[ \ ] using binary search. The program is erroneous. f (int Y[10] , int x) { int i, j, k; i= 0; j = 9; do { k = (i + j) / 2; if( Y[k] < x) i = k;else j = k; } while (Y[k] != x) && (i < j)) ; if(Y[k] == x) printf(" x is in the array ") ; else printf(" x is …
Official PYQ2008AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into two sub-lists each of which contains at least one-fifth of the elements. Let T(n)T(n) be the number of comparisons required to sort nn elements. Then
Official PYQ2008AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Consider the following C program that attempts to locate an element xx in an array Y[ ]Y[ \ ] using binary search. The program is erroneous. f (int Y[10] , int x) { int i, j, k; i= 0; j = 9; do { k = (i+ j) / 2; if( Y[k] < x) i = k;else j = k; } while (Y[k] != x) && (i < j)) ; if(Y[k] == x) printf(" x is in the array ") ; else printf(" x is …
Official PYQ2007AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Which of the following sorting algorithms has the lowest worse-case complexity?