Subject Wise PYQs Quiz on Algorithms GATE CS from 2025 to 2000
Question 1
Assuming P β NP, which of the following is TRUE?
NP-complete = NP
NP-complete β© P = ο
NP-hard = NP
P = NP-complete
Question 2
Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter
MultiDequeue(Q){
m = k
while (Q is not empty) and (m > 0) {
Dequeue(Q)
m = m β 1
}
}
What is the worst case time complexity of a sequence of n queue operations on an initially empty queue?
[Tex]\Theta{(n)}[/Tex]
[Tex]\Theta{(n+k)}[/Tex]
[Tex]\Theta{(nk)}[/Tex]
[Tex]\Theta{(n^{2})}[/Tex]
Question 3
Consider the following algorithm someAlgo that takes an undirected graph πΊ as input.
someAlgo(πΊ)
1. Let π£ be any vertex in πΊ. Run BFS on πΊ starting at π£. Let π’ be a vertex in πΊ at maximum distance from π£ as given by the BFS.
2. Run BFS on πΊ again with π’ as the starting vertex. Let π§ be the vertex at maximum distance from π’ as given by the BFS.
3. Output the distance between π’ and π§ in πΊ. The output of someAlgo(π) for the tree shown in the given figure is ___________. (Answer in integer)
6
Question 4
An array π΄ of length π with distinct elements is said to be bitonic if there is an index 1 β€ π β€ π such that π΄[1. . π] is sorted in the non-decreasing order and π΄[π + 1 . . π] is sorted in the non-increasing order.
Which ONE of the following represents the best possible asymptotic bound for the worst-case number of comparisons by an algorithm that searches for an element in a bitonic array π΄?
Ξ(π)
Ξ(1)
Ξ(log2 π)
Ξ(log π)
Question 5
A meld operation on two instances of a data structure combines them into one single instance of the same data structure. Consider the following data structures:
P: Unsorted doubly linked list with pointers to the head node and tail node of the list.
Q: Min-heap implemented using an array.
R: Binary Search Tree.
Which ONE of the following options gives the worst-case time complexities for meld operation on instances of size π of these data structures?
P: Ξ(1), Q: Ξ(π), R: Ξ(π)
P: Ξ(1), Q: Ξ(π log π), R: Ξ(π)
P: Ξ(π), Q: Ξ(π log π), R: Ξ(π 2 )
P: Ξ(1), Q: Ξ(π), R: Ξ(π log π)
Question 6
Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph G is/are TRUE?
A DFS tree of πΊ is a Shortest Path tree of G
Every non-tree edge of G with respect to a DFS tree is a forward/back edge.
If (π’, π£) is a non-tree edge of G with respect to a BFS tree, then the distances from the source vertex π to π’ and π£ in the BFS tree are within Β±1 of each other.
Both BFS and DFS can be used to find the connected components of G
Question 7
The maximum value of π₯ such that the edge between the nodes B and C is included in every minimum spanning tree of the given graph is _________ . (answer in integer)
5
Question 8
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?
1
N-1
N
2N-1
Question 9
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 π΄[0, β¦ ,29] be an array storing 30 distinct integers in descending order. The number of swap operations that will be performed, if the function fun() is called with π΄[0, β¦ ,29] as argument, is __________. (Answer in integer)
435
Question 10
Consider the following recurrence relation:
π(π) = 2π(π β 1) + π2π for π > 0, π(0) = 1.
Which ONE of the following options is CORRECT?
π(π) = Ξ(π22π)
π(π) = Ξ(π2π)
π(π) = Ξ((log π)22π)
π(π) = Ξ(4π)
There are 198 questions to complete.