Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Search results for recursion
104
votes
7
answers
1
GATE CSE 2017 Set 1 | Question: 36
Consider the C functions foo and bar given below: int foo(int val) { int x=0; while(val > 0) { x = x + foo(val--); } return val; } int bar(int val) { int x = 0; while(val > 0) { x ... in: Return of $6$ and $6$ respectively. Infinite loop and abnormal termination respectively. Abnormal termination and infinite loop respectively. Both terminating abnormally.
Consider the C functions foo and bar given below:int foo(int val) { int x=0; while(val 0) { x = x + foo(val ); } return val; }int bar(int val) { int x = 0; while(val 0)...
Arjun
25.3k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming-in-c
programming
normal
recursion
+
–
47
votes
11
answers
2
GATE CSE 2017 Set 1 | Question: 35
Consider the following two functions. void fun1(int n) { if(n == 0) return; printf("%d", n); fun2(n - 2); printf("%d", n); } void fun2(int n) { if(n == 0) return; printf("%d", n); ... printf("%d", n); } The output printed when $\text{fun1}(5)$ is called is $53423122233445$ $53423120112233$ $53423122132435$ $53423120213243$
Consider the following two functions.void fun1(int n) { if(n == 0) return; printf("%d", n); fun2(n - 2); printf("%d", n); } void fun2(int n) { if(n == 0) return; printf("...
Arjun
20.4k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming
normal
tricky
recursion
+
–
64
votes
8
answers
3
GATE CSE 2007 | Question: 44
In the following C function, let $n \geq m$. int gcd(n,m) { if (n%m == 0) return m; n = n%m; return gcd(m,n); } How many recursive calls are made by this function? $\Theta(\log_2n)$ $\Omega(n)$ $\Theta(\log_2\log_2n)$ $\Theta(\sqrt{n})$
In the following C function, let $n \geq m$.int gcd(n,m) { if (n%m == 0) return m; n = n%m; return gcd(m,n); }How many recursive calls are made by this function?$\Theta(\...
Kathleen
26.6k
views
Kathleen
asked
Sep 21, 2014
Algorithms
gatecse-2007
algorithms
recursion
time-complexity
normal
+
–
38
votes
3
answers
4
GATE CSE 2020 | Question: 46
Consider the following C functions. int fun1(int n) { static int i= 0; if (n > 0) { ++i; fun1(n-1); } return (i); } int fun2(int n) { static int i= 0; if (n>0) { i = i+ fun1 (n) ; fun2(n-1) ; } return (i); } The return value of $\text{fun}2 (5)$ is _________
Consider the following C functions.int fun1(int n) { static int i= 0; if (n 0) { ++i; fun1(n-1); } return (i); }int fun2(int n) { static int i= ...
Arjun
23.4k
views
Arjun
asked
Feb 12, 2020
Programming in C
gatecse-2020
numerical-answers
programming-in-c
recursion
2-marks
+
–
53
votes
5
answers
5
GATE CSE 2005 | Question: 81a
double foo(int n) { int i; double sum; if(n == 0) { return 1.0; } else { sum = 0.0; for(i = 0; i < n; i++) { sum += foo(i); } return sum; } } The space complexity of the above code is? $O(1)$ $O(n)$ $O(n!)$ $n^n$
double foo(int n) { int i; double sum; if(n == 0) { return 1.0; } else { sum = 0.0; for(i = 0; i < n; i++) { sum += foo(i); } return sum; } }The space complexity of the a...
Kathleen
19.1k
views
Kathleen
asked
Sep 22, 2014
Algorithms
gatecse-2005
algorithms
recursion
normal
space-complexity
+
–
59
votes
4
answers
6
GATE CSE 2014 Set 2 | Question: 40
Consider the following function. double f(double x){ if( abs(x*x - 3) < 0.01) return x; else return f(x/2 + 1.5/x); } Give a value $q$ (to $2$ decimals) such that $f(q)$ will return $q$:_____.
Consider the following function.double f(double x){ if( abs(x*x - 3) < 0.01) return x; else return f(x/2 + 1.5/x); }Give a value $q$ (to $2$ decimals) such that $f(q)$ wi...
go_editor
19.2k
views
go_editor
asked
Sep 28, 2014
Programming in C
gatecse-2014-set2
programming
recursion
numerical-answers
normal
+
–
41
votes
6
answers
7
GATE CSE 2016 Set 2 | Question: 37
Consider the following program: int f (int * p, int n) { if (n <= 1) return 0; else return max (f (p+1, n-1), p[0] - p[1]); } int main () { int a[] = {3, 5, 2, 6, 4}; printf(" %d", f(a, 5)); } Note: $\max (x, y)$ returns the maximum of $x$ and $y$. The value printed by this program is ________.
Consider the following program:int f (int * p, int n) { if (n <= 1) return 0; else return max (f (p+1, n-1), p[0] - p ); } int main () { int a[] = {3, 5, 2, 6, 4}; ...
Akash Kanase
13.6k
views
Akash Kanase
asked
Feb 12, 2016
Programming in C
gatecse-2016-set2
programming-in-c
normal
numerical-answers
recursion
+
–
49
votes
5
answers
8
GATE IT 2007 | Question: 27
The function f is defined as follows: int f (int n) { if (n <= 1) return 1; else if (n % 2 == 0) return f(n/2); else return f(3n - 1); } Assuming that arbitrarily large integers can be passed as a parameter to the function, consider the following ... values of $n \geq 1$. Which one of the following options is true of the above? i and iii i and iv ii and iii ii and iv
The function f is defined as follows:int f (int n) { if (n <= 1) return 1; else if (n % 2 == 0) return f(n/2); else return f(3n - 1); }Assuming that arbitrarily large int...
Ishrat Jahan
12.9k
views
Ishrat Jahan
asked
Oct 29, 2014
Programming in C
gateit-2007
programming
recursion
normal
+
–
0
votes
2
answers
9
C Programming - Recursion
What is the output of the below code? #include <stdio.h> void main() { static int var = 5; printf("%d ", var--); if (var) main(); } a. 1 2 3 4 5 b. 1 c. 5 4 3 2 1 d. Error
What is the output of the below code?#include <stdio.h void main() { static int var = 5; printf("%d ", var ); if (var) main(); }a. 1 2 3 4 5b. 1c. 5 4 3 2 1d. Error
Debargha Mitra Roy
100
views
Debargha Mitra Roy
asked
Apr 10
Programming in C
recursion
programming-in-c
programming
+
–
1
votes
1
answer
10
#Recursivefunctions
int bar(int val){ int x=0; while(val > 0){ x=x+bar(val -1); } return val; } Q: For bar(3) this function is supposed to be stuck in an infinite loop but I do not know how please can someone explain?
int bar(int val){int x=0;while(val 0){x=x+bar(val -1);}return val;}Q: For bar(3) this function is supposed to be stuck in an infinite loop but I do not know how please c...
sumitkumarsethi
81
views
sumitkumarsethi
asked
Apr 8
Programming in C
recursion
functions
+
–
32
votes
8
answers
11
GATE CSE 1991 | Question: 01,x
Consider the following recursive definition of $fib$: fib(n) := if n = 0 then 1 else if n = 1 then 1 else fib(n-1) + fib(n-2) The number of times $fib$ is called (including the first call) for evaluation of $fib(7)$ is___________.
Consider the following recursive definition of $fib$:fib(n) := if n = 0 then 1 else if n = 1 then 1 else fib(n-1) + fib(n-2)The number of times $fib$ is called (includin...
Kathleen
10.2k
views
Kathleen
asked
Sep 12, 2014
Programming in C
gate1991
programming
recursion
normal
numerical-answers
+
–
6
votes
1
answer
12
GO Classes Test Series 2024 | Mock GATE | Test 11 | Question: 48
Consider the following pair of mutually recursive functions. What does $g(g(2))$ evaluate to? int f(int n){ if (n==0) return 0; return f(n-1)+g(n-1); } int g(int n){ if (n==0) return 1; return g(n-1) + f(n); }
Consider the following pair of mutually recursive functions. What does $g(g(2))$ evaluate to?int f(int n){ if (n==0) return 0; return f(n-1)+g(n-1); } int g(int n){ if (n...
GO Classes
424
views
GO Classes
asked
Jan 13
Programming in C
goclasses2024-mockgate-11
goclasses
numerical-answers
programming
programming-in-c
recursion
2-marks
+
–
4
votes
2
answers
13
GO Classes Test Series 2024 | Mock GATE | Test 11 | Question: 21
Consider the following two blocks of code, found in separate files: /* main.c */ int main() { int i=0; foo(); return 0; } /* foo.c */ int i=1; void foo() { printf( %d , i); } What will happen when you attempt to ... ? It will fail to compile. It will fail to link. It will print " $0$ ". It will print " $1$ ".
Consider the following two blocks of code, found in separate files:/* main.c */ int main() { int i=0; foo(); return 0; }/* foo.c */ int i=1; void foo() { printf(“%d”,...
GO Classes
921
views
GO Classes
asked
Jan 13
Programming in C
goclasses2024-mockgate-11
goclasses
programming
programming-in-c
recursion
1-mark
+
–
35
votes
7
answers
14
GATE CSE 2018 | Question: 45
Consider the following program written in pseudo-code. Assume that $x$ and $y$ are integers. Count (x, y) { if (y !=1 ) { if (x !=1) { print("*"); Count (x/2, y); } else { y=y-1; Count (1024, y); } } } The number of times that the $print$ statement is executed by the call $Count(1024, 1024)$ is _____
Consider the following program written in pseudo-code. Assume that $x$ and $y$ are integers.Count (x, y) { if (y !=1 ) { if (x !=1) { print("*"); Count (x/2, y); } else {...
gatecse
13.2k
views
gatecse
asked
Feb 14, 2018
Algorithms
gatecse-2018
numerical-answers
algorithms
recursion
2-marks
+
–
0
votes
0
answers
15
testbook
Rohit Chakraborty
124
views
Rohit Chakraborty
asked
Dec 24, 2023
Programming in C
testbook-test-series
programming-in-c
recursion
+
–
37
votes
3
answers
16
GATE CSE 1994 | Question: 21
Consider the following recursive function: function fib (n:integer);integer; begin if (n=0) or (n=1) then fib := 1 else fib := fib(n-1) + fib(n-2) end; The above function is run on a computer with a stack of $64$ bytes. Assuming ... an address takes $2$ bytes each, estimate the maximum value of $n$ for which the stack will not overflow. Give reasons for your answer.
Consider the following recursive function:function fib (n:integer);integer; begin if (n=0) or (n=1) then fib := 1 else fib := fib(n-1) + fib(n-2) end;The above function i...
Kathleen
25.5k
views
Kathleen
asked
Oct 5, 2014
Programming in C
gate1994
programming
recursion
normal
descriptive
+
–
6
votes
3
answers
17
GO Classes Test Series 2024 | Programming | Test 2 | Question: 21
What will be the output of the following program? #include<stdio.h> int rec(int x, int y) { static int count = 0; if (x == 0) return count; count++; if (x > y) rec(x - y, y); else rec(x, y - x); return count; } main() { int i = 10, j = 2, n; n = rec(i, j); printf("%d", n); } $4$ $5$ $6$ Infinite loop
What will be the output of the following program?#include<stdio.h int rec(int x, int y) { static int count = 0; if (x == 0) return count; count++; if (x y) rec(x - y, y)...
GO Classes
411
views
GO Classes
asked
Apr 24, 2022
Programming in C
goclasses2024-programming-2-weekly-quiz
goclasses
programming
programming-in-c
recursion
output
2-marks
+
–
16
votes
3
answers
18
GATE CSE 2021 Set 2 | Question: 49
Consider the following $\text{ANSI C}$ program #include <stdio.h> int foo(int x, int y, int q) { if ((x<=0) && (y<=0)) return q; if (x<=0) return foo(x, y-q, q); if (y<=0) return foo(x-q, y, q); return foo(x, ... ); } int main( ) { int r = foo(15, 15, 10); printf( %d , r); return 0; } The output of the program upon execution is _________
Consider the following $\text{ANSI C}$ program#include <stdio.h int foo(int x, int y, int q) { if ((x<=0) && (y<=0)) return q; if (x<=0) return foo(x, y-q, q); if (y<=0)...
Arjun
8.3k
views
Arjun
asked
Feb 18, 2021
Algorithms
gatecse-2021-set2
algorithms
recursion
output
numerical-answers
2-marks
+
–
3
votes
3
answers
19
C Programming Recursion
#include<stdio.h> void print(int n) { printf("Hello "); if(n++ == 0) return ; print(n); n++; } int main() { void print(); print(-4); } How many times printf execute?? And How ??
#include<stdio.h void print(int n) { printf("Hello "); if(n++ == 0) return ; print(n); n++; } int main() { void print(); print(-4); }How many times printf execute?? And H...
Laxman Ghanchi
1.2k
views
Laxman Ghanchi
asked
May 19, 2023
Programming in C
programming-in-c
programming
recursion
+
–
44
votes
11
answers
20
GATE CSE 2016 Set 1 | Question: 35
What will be the output of the following $C$ program? void count (int n) { static int d=1; printf ("%d",n); printf ("%d",d); d++; if (n>1) count (n-1); printf ("%d",d); } void main(){ count (3); } $3 \ 1 \ 2 \ 2 \ 1 \ 3 \ 4 \ 4 \ 4$ $3 \ 1 \ 2 \ 1 \ 1 \ 1 \ 2 \ 2 \ 2$ $3 \ 1 \ 2 \ 2 \ 1 \ 3 \ 4$ $3 \ 1 \ 2 \ 1 \ 1 \ 1 \ 2$
What will be the output of the following $C$ program?void count (int n) { static int d=1; printf ("%d",n); printf ("%d",d); d++; if (n>1) count (n-1); printf ("%d",d); } ...
Sandeep Singh
15.5k
views
Sandeep Singh
asked
Feb 12, 2016
Programming in C
gatecse-2016-set1
programming-in-c
recursion
normal
+
–
Page:
1
2
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register