The GATE Grind

GATE Programming and Data Structures: Recursion – Previous Year Questions

11 GATE previous year questions on Recursion (Programming and Data Structures, Computer Science) with answers and explanations, from every paper.

  1. GATE 2017 CS Q45 (2 marks, Multiple choice) – Consider the following two functions. The output printed when `fun1(5)` is called is
  2. GATE 2017 CS Q46 (2 marks, Multiple choice) – Consider the C functions `foo` and `bar` given below: Invocations of `foo(3)` and `bar(3)` will result in:
  3. GATE 2016 CS Q45 (2 marks, Multiple choice) – What will be the output of the following C program?
  4. GATE 2018 CS Q31 (1 mark, Numerical answer) – Consider the following C program: The output of this program is .
  5. GATE 2018 CS Q55 (2 marks, Numerical answer) – Consider the following program written in pseudo-code. Assume that `x` and `y` are integers. The number of times that the `print` statement is…
  6. GATE 2019 CS Q36 (2 marks, Multiple choice) – Consider the following C function. Which one of the following will happen when the function `convert` is called with any positive integer n as…
  7. GATE 2026 CS (CS2) Q61 (2 marks, Numerical answer) – Consider the following ANSI C function. The maximum possible value that can be returned from this function is . (answer in integer) Note: Ignore…
  8. GATE 2026 CS (CS1) Q61 (2 marks, Numerical answer) – Consider the recursive functions represented by the following code segment: The smallest positive integer n for which `foo(n)` returns 5 is . (answer…
  9. GATE 2025 CS (CS1) Q61 (2 marks, Numerical answer) – The value printed by the given C program is . (Answer in integer)
  10. GATE 2024 CS (CS1) Q19 (1 mark, Multiple choice) – Consider the following C program: Assume that the input to the program from the command line is 1234 followed by a newline character. Which one of the…
  11. GATE 2020 CS Q56 (2 marks, Numerical answer) – Consider the following C functions. The return value of fun2(5) is .