Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Tests  >  Programming and Data Structures  >  Test: Recursion- 1 - Computer Science Engineering (CSE) MCQ

Test: Recursion- 1 - Computer Science Engineering (CSE) MCQ


Test Description

4 Questions MCQ Test Programming and Data Structures - Test: Recursion- 1

Test: Recursion- 1 for Computer Science Engineering (CSE) 2024 is part of Programming and Data Structures preparation. The Test: Recursion- 1 questions and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus.The Test: Recursion- 1 MCQs are made for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Recursion- 1 below.
Solutions of Test: Recursion- 1 questions in English are available as part of our Programming and Data Structures for Computer Science Engineering (CSE) & Test: Recursion- 1 solutions in Hindi for Programming and Data Structures course. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free. Attempt Test: Recursion- 1 | 4 questions in 35 minutes | Mock test for Computer Science Engineering (CSE) preparation | Free important questions MCQ to study Programming and Data Structures for Computer Science Engineering (CSE) Exam | Download free PDF with solutions
Test: Recursion- 1 - Question 1

Consider the following recursive function fun(x, y). What is the value of fun(4, 3)
int fun(int x, int y) 
{
  if (x == 0)
    return y;
  return fun(x - 1,  x + y);
}

Detailed Solution for Test: Recursion- 1 - Question 1

The function fun() calculates and returns ((1 + 2 … + x-1 + x) +y) which is x(x+1)/2 + y.

Test: Recursion- 1 - Question 2

Predict output of following program
#include <stdio.h>
int fun(int n)
{
    if (n == 4)
       return n;
    else return 2*fun(n+1);
}
int main()
{
   printf("%d ", fun(2));
   return 0;
}

Detailed Solution for Test: Recursion- 1 - Question 2

Fun(2) = 2 * Fun(3) and Fun(3) = 2 * Fun(4) ....(i)
Fun(4) = 4 ......(ii)
From equation (i) and (ii),
Fun(2) = 2 * 2 * Fun(4)
Fun(2) = 2 * 2 * 4
Fun(2) = 16. 

So, C is the correct answer

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Recursion- 1 - Question 3

What does the following function do?
int fun(int x, int y)
{
    if (y == 0)   return 0;
    return (x + fun(x, y-1));
}

Detailed Solution for Test: Recursion- 1 - Question 3

The function adds x to itself y times which is x*y.

Test: Recursion- 1 - Question 4

What does the following function print for n = 25?

void fun(int n)

{

if (n == 0)

return;

printf("%d", n%2);

fun(n/2);

}

Detailed Solution for Test: Recursion- 1 - Question 4

The function mainly prints binary representation in reverse order.

119 docs|30 tests
Information about Test: Recursion- 1 Page
In this test you can find the Exam questions for Test: Recursion- 1 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Recursion- 1, EduRev gives you an ample number of Online tests for practice

Top Courses for Computer Science Engineering (CSE)

Download as PDF

Top Courses for Computer Science Engineering (CSE)