1. >GATE CS
  2. >Programming and Data Structures
Found 3  QuestionsSET DEFAULT
Selected Filters
    GATE CS Programming and Data Structures Recursion
Exams
Years
Subjects
Topics

List of top Programming and Data Structures Questions on Recursion asked in GATE CS

Consider the following ANSI-C function.

int func(int start, int end){
    int length=end+1-start;
    if((length<1)||(start<0)||(end<0)){ return(0); }
    if(length%3==0){
        return(func(start+1, end));
    } else if(length%3==1){
        return(1+func(start, end-1));
    } else {
        return(func(start+2, end));
    }
}
The maximum possible value that can be returned from this function is ______.

Note: Ignore syntax errors (if any) in the function.
  • GATE CS - 2026
  • GATE CS
  • 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