Start learning →

GATE CSE Algorithms — practice questions

Explore 60 free Algorithms questions in GATE CSE Computer Science. Open each question or exercise to read its content, reference answers and available explanation.

Practise Algorithms with Quill →

Algorithms questions and exercises with answers

Showing questions 1–30 of 60.

Per the lecture, an algorithm is best described asRead the answer and worked solution →Mathematical analysis of an algorithm replaces the stopwatch withRead the answer and worked solution →Per the lecture, which of these is NOT counted as a single primitive operation?Read the answer and worked solution →Linear search over n elements for key x has best-case and worst-case running times ofRead the answer and worked solution →f(n) is in O(g(n)) means there exist constants c > 0 and n_0 ≥ 0 such that for all n ≥ n_0,Read the answer and worked solution →f(n) = 3n² + 5n + 8 is inRead the answer and worked solution →From slowest to fastest growth for large n, the correct order isRead the answer and worked solution →Per the lecture, the worst-case lower bound on the number of comparisons made by any comparison-based sort on n elements isRead the answer and worked solution →Why does pre-sorting data pay off in practice?Read the answer and worked solution →The recurrence relation for merge sort's running time isRead the answer and worked solution →Merging two already-sorted arrays of total size n takesRead the answer and worked solution →A sorting algorithm is called STABLE ifRead the answer and worked solution →Standard quick sort with the first element as pivot has worst caseRead the answer and worked solution →Compared to merge sort, standard quick sort isRead the answer and worked solution →Counting sort runs inRead the answer and worked solution →The three classical steps of any divide-and-conquer algorithm areRead the answer and worked solution →Karatsuba's recurrence for n-digit multiplication isRead the answer and worked solution →The recurrence T(n) = T(n/2) + O(1) for binary search solves toRead the answer and worked solution →Per the lecture, Strassen's algorithm for n×n matrix multiplication obeysRead the answer and worked solution →The recurrence T(n) = 2T(n/2) + 2 with T(1) = c solves by iteration toRead the answer and worked solution →Iteratively unrolling T(n) = T(n/2) + c, the total work after reaching T(1) isRead the answer and worked solution →Per the Master Theorem, the three cases for T(n) = a · T(n/b) + c n^d are decided by comparingRead the answer and worked solution →Applying the Master Theorem to merge sort, T(n) = 2T(n/2) + n, the matching case and result areRead the answer and worked solution →Which recurrence is the Master Theorem (as stated) NOT able to solve?Read the answer and worked solution →The defining feature of a greedy algorithm is that itRead the answer and worked solution →Any spanning tree of a graph with |V| vertices has how many edges?Read the answer and worked solution →If you remove an edge (u, v) from an MST T, the two resulting sub-treesRead the answer and worked solution →The running time of Kruskal's algorithm with Union-Find isRead the answer and worked solution →Prim's algorithm grows the MST byRead the answer and worked solution →Prim's algorithm with a Fibonacci heap runs inRead the answer and worked solution →

Worked practice questions

Per the lecture, an algorithm is best described as

  1. a finite, unambiguous sequence of steps for a defined problem
  2. any program written in a high-level language
  3. a benchmark suite for comparing CPU speeds
  4. a snippet of pseudo-code that compiles to assembly
Show answer and solution

Correct answer: A. a finite, unambiguous sequence of steps for a defined problem

An algorithm is language-agnostic and machine-agnostic: a finite, unambiguous sequence of steps for a defined problem. A program is one specific implementation a benchmark suite is a measurement harness pseudo-code is a writing notation. The algorithm itself is the abstract recipe.

Open this question →

Mathematical analysis of an algorithm replaces the stopwatch with

  1. running the code on 10,000 random inputs
  2. buying faster hardware to reduce variance
  3. counting operations as a function of input size
  4. writing the code in a faster language like C
Show answer and solution

Correct answer: C. counting operations as a function of input size

Mathematical analysis sidesteps hardware and language entirely by expressing the work the algorithm does as a function of input size. **The other options are still empirical:** they may speed up the experiment but cannot generalise to unseen inputs or hardware.

Open this question →

Per the lecture, which of these is NOT counted as a single primitive operation?

  1. assigning a value to a variable
  2. comparing two scalar values like a < b
  3. accessing one cell of an array, A[i]
  4. sorting an n-element array into ascending order
Show answer and solution

Correct answer: D. sorting an n-element array into ascending order

Primitive operations are constant-time atomic steps: assignment, comparison, arithmetic, array indexing, method call/return. Sorting n elements is itself a multi-step algorithm whose cost depends on n. It is the THING we count primitive ops for, not a primitive op itself.

Open this question →

How to practise

  1. Choose a Algorithms question and try to work out your answer.
  2. Open the question to check the correct answer and read its worked solution.
  3. Continue in the app for bite-sized lessons, explanations and review with Quill. You can start without creating an account.

More Computer Science topics