1. Home
  2. Programming and Data Stru...

Filters

Found 4 Questions

Set Default
Subjects
Topics

List of top Programming and Data Structures Questions on Recursion

Consider the following Python code snippet.
def f(a, b):
    if (a == 0):
        return b
    if (a % 2 == 1):
        return 2 * f((a - 1) / 2, b)
    return b + f(a - 1, b)

print(f(15, 10))
The value printed by the code snippet is 160 (Answer in integer).
  • GATE DA - 2025
  • GATE DA
  • Programming and Data Structures
  • Recursion

Consider the following Python code snippet.

def f(a, b):
    if (a == 0):
        return b
    if (a % 2 == 1):
        return 2 * f((a - 1) / 2, b)
    return b + f(a - 1, b)

print(f(15, 10))

The value printed by the code snippet is 160 (Answer in integer).

  • GATE DA - 2025
  • GATE DA
  • Programming and Data Structures
  • Recursion

Consider the following ANSI C function: 

int SomeFunction(int x, int y) 
{
if ((x == 1) || (y == 1)) return 1; 
if (x == y) return x; 
if (x > y) return SomeFunction(x - y, y); 
if (y > x) return SomeFunction(x, y - x); 
} 

The value returned by SomeFunction(15, 255) is \(\underline{\hspace{2cm}}\).

  • GATE CS - 2021
  • GATE CS
  • Programming and Data Structures
  • Recursion

Consider the following ANSI C program.

 

The output of the program upon execution is \(\underline{\hspace{2cm}}\).

  • GATE CS - 2021
  • GATE CS
  • Programming and Data Structures
  • Recursion
contact us
terms & conditions
Privacy & Policy
© 2026 Patronum Web Private Limited