Algorithms — Solved PYQ & Mock Arena
Topic-wise Algorithms previous-year GATE & UGC NET questions with step-by-step LaTeX solutions
Using Kadane’s Algorithm, what is the maximum contiguous subarray sum of the array [-2, 1, -3, 4, -1, 2, 1, -5, 4]?
What is the length of the Longest Common Subsequence (LCS) between strings X = "AGGTAB" and Y = "GXTXAYB"?
The complete undirected graph ( labeled vertices) has how many distinct Spanning Trees (by Cayley’s Formula)?
Assume . Which of the following complexity-theoretic statements are TRUE?
What is the minimum number of scalar multiplications required to multiply four matrices ?
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?
Let be a connected, weighted undirected graph with all edge weights strictly distinct. Which of the following statements are ALWAYS TRUE?
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 elements?
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"?
What is the worst-case time complexity to sort integers lying in the range in the RAM model?
How many inversions (pairs such that ) exist in the array ?
An array of distinct integers is almost sorted: every element is at distance at most (, e.g. ) from its final sorted index. Which sorting algorithm achieves the tightest worst-case asymptotic runtime?
Suppose problem is known to be NP-Complete, and we want to prove that a new decision problem is also NP-Complete. Which polynomial-time reduction must we construct?
Five characters have frequencies . Using Huffman optimal prefix coding, what is the total weighted number of bits required to encode all characters?
Which sorting algorithm performs the minimum number of comparisons () when the input array is already sorted in ascending order?
What is the length of the Longest Common Subsequence (LCS) of strings and ?
What is the worst-case time complexity of Dijkstra’s single-source shortest path algorithm on a graph implemented using a Binary Min-Heap adjacency list?
Consider the recurrence relation for and . Which of the following is the tightest asymptotic bound for ?