Algorithms · Previous year questions
Searching and Sorting Algorithms
23 questions from GATE CS 2012 to 2026, newest first.
Questions
GATE CS 2026 Set 2, Q.38
Consider an array of integers of size . The indices of run from to . An algorithm is to be designed to check whether satisfies the condition given below.…
Searching and Sorting Algorithms
GATE CS 2025 Set 1, Q.33
The pseudocode of a function
fun()is given below: fun(int A[0,...,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 be...Searching and Sorting Algorithms
GATE CS 2025 Set 2, Q.20
Consider an unordered list of 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?
Searching and Sorting Algorithms
GATE CS 2025 Set 2, Q.41
An array of length with distinct elements is said to be bitonic if there is an index such that is sorted in the non-decreasing order and…
Searching and Sorting Algorithms · Divide and Conquer
GATE CS 2024 Set 1, Q.17
Given an integer array of size , we want to check if the array is sorted (in either ascending or descending order). An algorithm solves this problem by making a single pass t...
Asymptotic Analysis and Time/Space Complexity · Searching and Sorting Algorithms
GATE CS 2021 Set 1, Q.12 (CS Q.2)
Let be an array containing integers. Let be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum value...
Searching and Sorting Algorithms
GATE CS 2021 Set 1, Q.19 (CS Q.9)
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 (among the array elements) to sort the ab...
Searching and Sorting Algorithms
GATE CS 2019, Q.30 (CS Q.20)
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 the pivot element gets placed...
Searching and Sorting Algorithms
GATE CS 2017 Set 1, Q.48 (CS Q.48)
Let 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 such that is 1 by probing t...
Searching and Sorting Algorithms
GATE CS 2017 Set 2, Q.3 (CS Q.3)
Match the algorithms with their time complexities: | Algorithm | Time complexity | | :--- | :--- | | (P) Towers of Hanoi with disks | (i) | | (Q) Binary search...
Asymptotic Analysis and Time/Space Complexity · Searching and Sorting Algorithms
GATE CS 2017 Set 2, Q.43 (CS Q.43)
Consider the following snippet of a C program. Assume that
swap(&x, &y)exchanges the contents ofxandy. int main() { int array[] = {3, 5, 1, 4, 6, 2}; int done = 0...Pointers, Arrays and Strings · Searching and Sorting Algorithms
GATE CS 2016 Set 1, Q.23 (CS Q.13)
The worst case running times of Insertion sort, Merge sort and Quick sort, respectively, are:
Searching and Sorting Algorithms
GATE CS 2016 Set 2, Q.23 (CS Q.13)
Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE? I. Quicksort...
Searching and Sorting Algorithms
GATE CS 2015 Set 2, Q.32 (CS Q.22)
An unordered list contains distinct elements. The number of comparisons to find an element in this list that is neither maximum nor minimum is
Searching and Sorting Algorithms
GATE CS 2015 Set 2, Q.55 (CS Q.45)
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 ofa[]a...Searching and Sorting Algorithms
GATE CS 2015 Set 3, Q.37 (CS Q.27)
Assume that a mergesort algorithm in the worst case takes 30 seconds for an input of size 64. Which of the following most closely approximates the maximum input size of a proble...
Searching and Sorting Algorithms · Asymptotic Analysis and Time/Space Complexity
GATE CS 2014 Set 1, Q.24 (CS Q.14)
Let be a quicksort program to sort numbers in ascending order using the first element as the pivot. Let and be the number of comparisons made by for the inpu...
Searching and Sorting Algorithms
GATE CS 2014 Set 1, Q.49 (CS Q.39)
The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is _________________.
Searching and Sorting Algorithms
GATE CS 2014 Set 3, Q.24 (CS Q.14)
You have an array of 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...
Searching and Sorting Algorithms
GATE CS 2014 Set 3, Q.52 (CS Q.42)
Consider the C function given below. Assume that the array listA contains n (> 0) elements, sorted in ascending order. int ProcessArray(int *listA, int x, int n) { int i, j...
Searching and Sorting Algorithms
GATE CS 2013, Q.6 (CS Q.6)
Which one of the following is the tightest upper bound that represents the number of swaps required to sort numbers using selection sort?
Searching and Sorting Algorithms
GATE CS 2013, Q.30 (CS Q.30)
The number of elements that can be sorted in time using heap sort is
Searching and Sorting Algorithms
GATE CS 2012, Q.39 (CS Q.39)
A list of strings, each of length , is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is
Searching and Sorting Algorithms · Asymptotic Analysis and Time/Space Complexity