Sorting: GATE CS Previous Year Questions

Sorting · Algorithms

24 questions · asked in 15 of 27 years (2000–2026)

MCQ 22 · NAT 21-mark 17 · 2-mark 7

2000Questions per year2026

Questions 6–10 of 24

Q6GATE 2015 (Session 1)1 markMCQ−0.33 if wrong
Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting n ( ≥\geq2) numbers? In the recurrence equations given in the options below, c is a constant.

Q7GATE 2015 (Session 2)2 marksMCQ−0.67 if wrong
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[] 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 part. In addition, it moves the pivot so that the pivot is the last element of the left part. The return value is the number of elements in the left part.
The following partially given function in the C programming language is used to find the kthk^{th} smallest element in an array a[ ] of size n using the partition function. We assume k≤nk \leq n
  int kth_smallest(int a[], int n, int k)
{
    int left_end = partition(a,n);
    if ( left_end+1 == k ){
         return a[left_end];
    }
    if ( left_end+1 > k ){
         return kth_smallest( ________ );
    } else {
         return kth_smallest( ________ );
    }
} 

The missing argument lists are respectively

Q8GATE 2015 (Session 3)2 marksMCQ−0.67 if wrong
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 problem that can be solved in 6 minutes?

Q9GATE 2014 (Session 1)1 markMCQ−0.33 if wrong
Let P be a quick sort program to sort numbers in ascending order using the first element as the pivot. Let t1 and t2 be the number of comparisons made by P for the inputs [1 2 3 4 5] and [4 1 5 3 2] respectively. Which one of the following holds?

Q10GATE 2014 (Session 3)1 markMCQ−0.33 if wrong
You have an array of n elements. Suppose you implement quick sort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is

Keep practising

Topics in Algorithms

All CS topics ›