∑GateAndNet
PlannerSign Up

Algorithms — Solved PYQ & Mock Arena

Topic-wise Algorithms previous-year GATE & UGC NET questions with step-by-step LaTeX solutions

Showing 18 questions in AlgorithmsClick A / B / C / D for instant verification
Q1GATE CS 2023AlgorithmsNATEASY
+1M • 0 Neg

Using Kadane’s Algorithm, what is the maximum contiguous subarray sum of the array [-2, 1, -3, 4, -1, 2, 1, -5, 4]?

Q2GATE CS 2019AlgorithmsNATEASY
+2M • 0 Neg

What is the length of the Longest Common Subsequence (LCS) between strings X = "AGGTAB" and Y = "GXTXAYB"?

Q3GATE CS 2020AlgorithmsNATMEDIUM
+2M • 0 Neg

The complete undirected graph K6K_6 (66 labeled vertices) has how many distinct Spanning Trees (by Cayley’s Formula)?

Q4GATE CS 2025 MSQAlgorithmsMSQMEDIUM
+2M • 0 Neg

Assume P≠NP\mathbf{P \neq NP}. Which of the following complexity-theoretic statements are TRUE?

☑️ Multiple Select Question — pick one or more options, then click Check Answer.
Q5GATE CS 2016AlgorithmsNATMEDIUM
+2M • 0 Neg

What is the minimum number of scalar multiplications required to multiply four matrices M1(10×20),  M2(20×50),  M3(50×1),  M4(1×100)M_1(10 \times 20),\; M_2(20 \times 50),\; M_3(50 \times 1),\; M_4(1 \times 100)?

Q6GATE CS 2021AlgorithmsNATMEDIUM
+2M • 0 Neg

Five characters a, b, c, d, e occur with frequencies 10, 15, 12, 3, 4 respectively in a file. What is the total number of bits needed to encode the file using an optimal Huffman prefix code?

Q7GATE CS 2024 MSQAlgorithmsMSQMEDIUM
+2M • 0 Neg

Let G=(V,E)G = (V, E) be a connected, weighted undirected graph with all edge weights strictly distinct. Which of the following statements are ALWAYS TRUE?

☑️ Multiple Select Question — pick one or more options, then click Check Answer.
Q8GATE CS 2018AlgorithmsNATEASY
+1M • 0 Neg

What is the maximum number of key comparisons made by standard iterative Binary Search (A[mid] == x, <, > counted as 1 three-way probe per iteration) when searching in a sorted array of 1,0001,000 elements?

Q9GATE CS 2022AlgorithmsMCQMEDIUM
+2M • -0.67

In the Knuth-Morris-Pratt (KMP) string matching algorithm, what is the LPS[] (Longest Proper Prefix which is also a Suffix) array for the pattern P = "ABABACA"?

⚡ Click an option above to verify instantly
Q10GATE CS 2021 Set-2AlgorithmsMCQMEDIUM
+2M • -0.67

What is the worst-case time complexity to sort nn integers lying in the range [0,  n4−1][0, \; n^4 - 1] in the RAM model?

⚡ Click an option above to verify instantly
Q11GATE CS 2023AlgorithmsNATEASY
+1M • 0 Neg

How many inversions (pairs i<ji < j such that A[i]>A[j]A[i] > A[j]) exist in the array A=[8,4,2,1,3,5]A = [8, 4, 2, 1, 3, 5]?

Q12GATE CS 2025AlgorithmsMCQMEDIUM
+2M • -0.67

An array of nn distinct integers is almost sorted: every element is at distance at most kk (k≪nk \ll n, e.g. k=4k = 4) from its final sorted index. Which sorting algorithm achieves the tightest worst-case asymptotic runtime?

⚡ Click an option above to verify instantly
Q13UGC NET / GATE AlgoAlgorithmsMCQMEDIUM
+2M • -0.67

Suppose problem AA is known to be NP-Complete, and we want to prove that a new decision problem B∈NPB \in \text{NP} is also NP-Complete. Which polynomial-time reduction must we construct?

⚡ Click an option above to verify instantly
Q14GATE CS AlgorithmsAlgorithmsMCQMEDIUM
+2M • -0.67

Five characters have frequencies 5,9,12,13,165, 9, 12, 13, 16. Using Huffman optimal prefix coding, what is the total weighted number of bits required to encode all 5555 characters?

⚡ Click an option above to verify instantly
Q15GATE CS AlgorithmsAlgorithmsMCQEASY
+1M • -0.33

Which sorting algorithm performs the minimum number of comparisons (Θ(n)\Theta(n)) when the input array is already sorted in ascending order?

⚡ Click an option above to verify instantly
Q16GATE CS AlgorithmsAlgorithmsMCQMEDIUM
+2M • -0.67

What is the length of the Longest Common Subsequence (LCS) of strings X="AGGTAB"X = \text{"AGGTAB"} and Y="GXTXAYB"Y = \text{"GXTXAYB"}?

⚡ Click an option above to verify instantly
Q17GATE CS AlgorithmsAlgorithmsMCQMEDIUM
+2M • -0.67

What is the worst-case time complexity of Dijkstra’s single-source shortest path algorithm on a graph G=(V,E)G = (V, E) implemented using a Binary Min-Heap adjacency list?

⚡ Click an option above to verify instantly
Q18GATE CS 2023AlgorithmsMCQMEDIUM
+2M • -0.67

Consider the recurrence relation T(n)=8 T ⁣(n2)+n3log⁡2nT(n) = 8\,T\!\left(\frac{n}{2}\right) + n^3 \log_2 n for n>1n > 1 and T(1)=1T(1) = 1. Which of the following is the tightest asymptotic bound for T(n)T(n)?

⚡ Click an option above to verify instantly