A highly popular method used to prepare for the GATE Exam is to sincerely practise all the previous years’ GATE Questions to gain perfection. Candidates can practise, analyse and understand concepts while solving them. It will also help you strengthen your time management skills. We have attempted to compile, here in this article, a collection of GATE Questions on Algorithm.
Candidates are urged to practise these Algorithm GATE previous years’ questions to get the best results. Algorithm is an important topic in the GATE CSE question paper, and solving these questions will help the candidates to prepare more proficiently for the GATE exams. Therefore, candidates can find the GATE Questions for Algorithm in this article to solve and practise well before the exams. They can also refer to these GATE previous year question papers and start preparing for the exams.
GATE Questions on Algorithm
- There are n unsorted arrays: A1, A2, …, An. Assume that n is odd. Each of A1, A2, …, An contains n distinct elements. There are no common elements between any two arrays. The worst-case time complexity of computing the median of the medians of A1, A2, …, An is ________.
- O(n)
- O(nlogn)
- O(n2logn)
- O(n2)
- 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 in the worst possible location in the first round of partitioning (rounded off to 2 decimal places) is ________.
- 0.08
- 0.1
- 1
- 0
- 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 and II only
- I and III only
- II and IV only
- I and IV only
- Consider the following array of elements.
- 4
- 5
- 2
- 3
- 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 recurrence equations given in the options below, c is a constant.
- T(n) = 2T(n/2) + cn
- T(n) = T(n-1) + T(1) + cn
- T(n) = 2T(n-1) + cn
- T(n) = T(n/2) + cn
- A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is: 10, 8, 5, 3, 2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is _________.
- 10, 8, 7, 3, 2, 1, 5
- 10, 8, 7, 2, 3, 1, 5
- 10, 8, 7, 1, 2, 3, 5
- 10, 8, 7, 5, 3, 2, 1
- An unordered list contains n distinct elements. The number of comparisons to find an element in this list that is neither maximum nor minimum is _________.
- Θ(nlogn)
- Θ(n)
- Θ(logn)
- Θ(1)
- You have an array of n 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 ________.
- Θ(n2)
- Θ(nlogn)
- Θ(n)
- None of the above
- Let P be a QuickSort Program to sort numbers in ascending order using the first element as 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?
- t1 = 5
- t1 < t2
- t1 > t2
- t1 = t2
- Which of the following statement(s) is/are correct regarding the Bellman-Ford shortest path algorithm?
- P only
- Q only
- Both P and Q
- Neither P nor Q
- The usual Θ(n2) 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 __________.
- Remain Θ(n2)
- Become Θ(n(logn)2)
- Become Θ(nlogn)
- Become Θ(n)
- 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?
- O(n)
- O(nlogn)
- O(n2)
- O(n!)
- If one uses a straight two-way merge sort algorithm to sort the following elements in ascending order 20, 47, 15, 8, 9, 4, 40, 30, 12, 17, then the order of these elements after the second pass of the algorithm is _________.
- 8, 9, 15, 20, 47, 4, 12, 17, 30, 40
- 8, 15, 20, 47, 4, 9, 30, 40, 12, 17
- 15, 20, 47, 4, 8, 9, 12, 30, 40, 17
- 4, 8, 9, 15, 20, 47, 12, 17, 30, 40
- A sorting technique is called stable if __________.
- It takes O(nlogn) time
- It maintains the relative order of occurrence of non-distinct elements
- It uses divide and conquer paradigm
- It takes O(n) space
- For merging two sorted lists of sizes m and n into a sorted list of size m+n, we require comparisons of _________.
- O(m)
- O(n)
- O(m+n)
- O(logm + logn)
(GATE CSE 2019)
Answer (d)
(GATE CSE 2019)
Answer (a)
I. Quicksort runs in Θ(n2) time
II. Bubblesort runs in Θ(n2) time
III. Mergesort runs in Θ(n) time
IV. Insertion sort runs in Θ(n) time
(GATE CSE 2016 Set 2)
Answer (d)
〈89,19,50,17,12,15,2,5,7,11,6,9,100〉
The minimum number of interchanges needed to convert it into a max-heap is _______.
(GATE CSE 2015 Set 3)
Answer (d)
(GATE CSE 2015 Set 1)
Answer (b)
(GATE CSE 2014 Set 2)
Answer (a)
(GATE CSE 2015 Set 2)
Answer (d)
(GATE CSE 2014 Set 3)
Answer (a)
(GATE CSE 2014 Set 1)
Answer (c)
P: Always finds a negative weighted cycle, if one exists.
Q: Finds whether any negative weighted cycle is reachable from the source.
(GATE CSE 2009)
Answer (b)
(GATE CSE 2003)
Answer (a)
(GATE CSE 2001)
Answer (c)
(GATE CSE 1999)
Answer (b)
(GATE CSE 1999)
Answer (b)
(GATE CSE 1995)
Answer (c)
Comments