Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged recursion
5
votes
5
answers
181
Number of moves of smallest disc in tower of Hanoi
______ is the number of moves of the smallest disc in Tower of Hanoi implementation where the tower consisting of 17 discs (numbered from 0 to 16) Answer given: $2^{16}$ = 65536 Please explain
______ is the number of moves of the smallest disc in Tower of Hanoi implementation where the tower consisting of 17 discs (numbered from 0 to 16)Answer given: $2^{16}$ ...
shikharV
3.2k
views
shikharV
asked
Nov 15, 2015
DS
algorithms
programming
recursion
+
–
1
votes
1
answer
182
Finding time complexity of Dynamic programming problem
The answer to the above problem is A but I am expecting it to be D as constant amount of work is required to solve each subproblem.
The answer to the above problem is A but I am expecting it to be D as constant amount of work is required to solve each subproblem.
shikharV
1.0k
views
shikharV
asked
Nov 15, 2015
Algorithms
algorithms
time-complexity
recursion
data-structures
made-easy-booklet
+
–
1
votes
1
answer
183
time complexity=?
void xyz(char *s) { if(s[0]=='\0') return; xyz(s+1); xyz(s+1); printf("%c",s[0]); } void main() { xyz("123"); } if the input string constant is of length $n$ then what is the time complexity? $O(2^n)$ $O(n^2)$ $O(n)$ $O(n\log n)$
void xyz(char *s) { if(s[0]=='\0') return; xyz(s+1); xyz(s+1); printf("%c",s[0]); } void main() { xyz("123"); }if the input string constant is of length $n$ then what is ...
Nishikant kumar
496
views
Nishikant kumar
asked
Nov 11, 2015
Algorithms
recursion
+
–
24
votes
2
answers
184
TIFR CSE 2011 | Part B | Question: 38
Consider the class of recursive and iterative programs. Which of the following is false? Recursive programs are more powerful than iterative programs. For every iterative program there is an equivalent recursive program. ... memory management. Recursive programs do not terminate sometimes. Iterative programs and recursive programs are equally expressive.
Consider the class of recursive and iterative programs. Which of the following is false?Recursive programs are more powerful than iterative programs.For every iterative p...
makhdoom ghaya
6.4k
views
makhdoom ghaya
asked
Oct 25, 2015
Programming in C
tifr2011
recursion
programming
+
–
16
votes
2
answers
185
TIFR CSE 2010 | Part B | Question: 31
Consider the following computation rules. Parallel-outermost rule: Replace all the outermost occurrences of F (i.e., all occurrences of F which do not occur as arguments of other F's) simultaneously. Parallel - innermost rule: Replace all the innermost ... $0$ and $0$ respectively $w$ and $w$ respectively $w$ and $1$ respectively none of the above
Consider the following computation rules. Parallel-outermost rule: Replace all the outermost occurrences of F (i.e., all occurrences of F which do not occur as arguments ...
Arjun
1.6k
views
Arjun
asked
Oct 10, 2015
Programming in C
tifr2010
programming
recursion
+
–
3
votes
1
answer
186
How to solve recursion problem in less time?
I'm solving questions of recursion. But those problems are hard to debug in few minutes? Have you any such method that solve recursive problem in less time? I have written problem below: please help me in this problem: int fun(int n){ int ... ; return; } The return value of fun(5) is ________. How to solve this problem in less time? Please help me.
I'm solving questions of recursion. But those problems are hard to debug in few minutes? Have you any such method that solve recursive problem in less time? I have writte...
admin
1.7k
views
admin
asked
Sep 15, 2015
Programming in C
programming-in-c
recursion
+
–
1
votes
1
answer
187
How many recursive calls are made by gcd function ?
I have already gone through the links of stackoverflow on this topic but still couldn't understand it clearly , so please explain the logic behind this .
I have already gone through the links of stackoverflow on this topic but still couldn't understand it clearly , so please explain the logic behind this .
radha gogia
2.2k
views
radha gogia
asked
Jul 21, 2015
Algorithms
algorithms
recursion
time-complexity
normal
+
–
0
votes
1
answer
188
Size of stack required is ?
A(n) { if(n>=1) { A(n-1); // statement 1 print n; //statement 2 A(n-1);// statement 3 } }
A(n) { if(n>=1) { A(n-1); // statement 1 print n; //statement 2 A(n-1);// statement 3 } }
_xor_
795
views
_xor_
asked
May 27, 2015
Algorithms
recursion
+
–
41
votes
4
answers
189
GATE CSE 2015 Set 2 | Question: 15
Consider the following function written in the C programming langauge : void foo(char *a) { if (*a && *a != ' ') { foo(a+1); putchar(*a); } } The output of the above function on input "$ABCD \ EFGH$" is $ABCD \ EFGH$ $ABCD$ $HGFE \ DCBA$ $DCBA$
Consider the following function written in the C programming langauge :void foo(char *a) { if (*a && *a != ' ') { foo(a+1); putchar(*a); } }The output of the above func...
go_editor
14.5k
views
go_editor
asked
Feb 12, 2015
Programming in C
gatecse-2015-set2
programming
programming-in-c
normal
recursion
+
–
0
votes
4
answers
190
what is the output of foo(10)?
int foo(unsigned int n) { int c,x=0; while(n!=0) { if(n&01) x++; n>>=1; } return c; }
int foo(unsigned int n) { int c,x=0; while(n!=0) { if(n&01) x++; n>>=1; } return c; }
Tariq Husain Khan
1.4k
views
Tariq Husain Khan
asked
Dec 10, 2014
Programming in C
programming
recursion
+
–
49
votes
5
answers
191
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
13.0k
views
Ishrat Jahan
asked
Oct 29, 2014
Programming in C
gateit-2007
programming
recursion
normal
+
–
18
votes
3
answers
192
GATE IT 2008 | Question: 83
Consider the code fragment written in C below : void f (int n) { if (n <= 1) { printf ("%d", n); } else { f (n/2); printf ("%d", n%2); } } Which of the following implementations will produce the same output for $f(173)$ as the above code? ... { printf ("%d", n%2); f (n/2); } } Both $P1$ and $P2$ $P2$ only $P1$ only Neither $P1$ nor $P2$
Consider the code fragment written in C below : void f (int n) { if (n <= 1) { printf ("%d", n); } else { f (n/2); printf ("%d", n%2); } }Which of the following im...
Ishrat Jahan
8.9k
views
Ishrat Jahan
asked
Oct 29, 2014
Algorithms
gateit-2008
algorithms
recursion
identify-function
normal
+
–
15
votes
4
answers
193
GATE IT 2008 | Question: 82
Consider the code fragment written in C below : void f (int n) { if (n <=1) { printf ("%d", n); } else { f (n/2); printf ("%d", n%2); } } What does f(173) print? $010110101$ $010101101$ $10110101$ $10101101$
Consider the code fragment written in C below :void f (int n) { if (n <=1) { printf ("%d", n); } else { f (n/2); printf ("%d", n%2); } }What does f(173) print?$010110101$...
Ishrat Jahan
9.3k
views
Ishrat Jahan
asked
Oct 29, 2014
Algorithms
gateit-2008
algorithms
recursion
identify-function
normal
+
–
14
votes
1
answer
194
GATE CSE 1995 | Question: 2.9
A language with string manipulation facilities uses the following operations head(s): first character of a string tail(s): all but exclude the first character of a string concat(s1, s2): s1s2 For the string "$acbc$" what will be the output of concat(head(s), head(tail(tail(s)))) $ac$ $bc$ $ab$ $cc$
A language with string manipulation facilities uses the following operationshead(s): first character of a string tail(s): all but exclude the first character of a stringc...
Kathleen
4.3k
views
Kathleen
asked
Oct 8, 2014
Algorithms
gate1995
algorithms
normal
recursion
+
–
37
votes
3
answers
195
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
+
–
26
votes
4
answers
196
GATE CSE 2010 | Question: 35
What is the value printed by the following C program? #include<stdio.h> int f(int *a, int n) { if (n <= 0) return 0; else if (*a % 2 == 0) return *a+f(a+1, n-1); else return *a - f(a+1, n-1); } int main() { int a[] = {12, 7, 13, 4, 11, 6}; printf("%d", f(a, 6)); return 0; } $-9$ $5$ $15$ $19$
What is the value printed by the following C program?#include<stdio.h int f(int *a, int n) { if (n <= 0) return 0; else if (*a % 2 == 0) return *a+f(a+1, n-1); else retur...
go_editor
11.7k
views
go_editor
asked
Sep 30, 2014
Algorithms
gatecse-2010
algorithms
recursion
identify-function
normal
+
–
18
votes
3
answers
197
GATE CSE 2011 | Question: 48
Consider the following recursive C function that takes two arguments. unsigned int foo(unsigned int n, unsigned int r) { if (n>0) return ((n%r) + foo(n/r, r)); else return 0; } What is the return value of the function $\text{foo}$ when it is called as $\text{foo(345, 10)}$? $345$ $12$ $5$ $3$
Consider the following recursive C function that takes two arguments.unsigned int foo(unsigned int n, unsigned int r) { if (n>0) return ((n%r) + foo(n/r, r)); else return...
go_editor
9.0k
views
go_editor
asked
Sep 29, 2014
Algorithms
gatecse-2011
algorithms
recursion
identify-function
normal
+
–
59
votes
4
answers
198
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
+
–
29
votes
6
answers
199
GATE CSE 1998 | Question: 2.12
What value would the following function return for the input $x=95$? Function fun (x:integer):integer; Begin If x > 100 then fun = x – 10 Else fun = fun(fun (x+11)) End; $89$ $90$ $91$ $92$
What value would the following function return for the input $x=95$?Function fun (x:integer):integer; Begin If x 100 then fun = x – 10 Else fun = fun(fun (x+11)) End;$...
Kathleen
13.9k
views
Kathleen
asked
Sep 25, 2014
Algorithms
gate1998
algorithms
recursion
identify-function
normal
+
–
53
votes
5
answers
200
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.2k
views
Kathleen
asked
Sep 22, 2014
Algorithms
gatecse-2005
algorithms
recursion
normal
space-complexity
+
–
26
votes
4
answers
201
GATE CSE 2005 | Question: 31
Consider the following C-program: void foo (int n, int sum) { int k = 0, j = 0; if (n == 0) return; k = n % 10; j = n/10; sum = sum + k; foo (j, sum); printf ("%d,",k); } int main() { int a = 2048, sum = 0; foo(a, sum); printf("%d\n", sum); } What ... print? $\text{8, 4, 0, 2, 14}$ $\text{8, 4, 0, 2, 0}$ $\text{2, 0, 4, 8, 14}$ $\text{2, 0, 4, 8, 0}$
Consider the following C-program:void foo (int n, int sum) { int k = 0, j = 0; if (n == 0) return; k = n % 10; j = n/10; sum = sum + k; foo (j, sum); printf ("%d,",k); } ...
Kathleen
13.2k
views
Kathleen
asked
Sep 22, 2014
Algorithms
gatecse-2005
algorithms
identify-function
recursion
normal
+
–
32
votes
2
answers
202
GATE CSE 2009 | Question: 53
A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences $X[m]$ and $Y[n]$ of lengths $m$ and $n$, respectively with indexes of $X$ and $Y$ starting from $0$. We wish to find the ... $\text{expr2} = \max\left(l\left(i-1, j-1\right), l\left(i,j\right)\right)$
A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences $X[m]$ and $Y[n]$ of lengths ...
Kathleen
9.3k
views
Kathleen
asked
Sep 22, 2014
Algorithms
gatecse-2009
algorithms
normal
dynamic-programming
recursion
+
–
26
votes
4
answers
203
GATE CSE 2009 | Question: 18
Consider the program below: #include <stdio.h> int fun(int n, int *f_p) { int t, f; if (n <= 1) { *f_p = 1; return 1; } t = fun(n-1, f_p); f = t + *f_p; *f_p = t; return f; } int main() { int x = 15; printf("%d/n", fun(5, &x)); return 0; } The value printed is: $6$ $8$ $14$ $15$
Consider the program below:#include <stdio.h int fun(int n, int *f_p) { int t, f; if (n <= 1) { *f_p = 1; return 1; } t = fun(n-1, f_p); f = t + *f_p; *f_p = t; return f;...
Kathleen
11.3k
views
Kathleen
asked
Sep 22, 2014
Algorithms
gatecse-2009
algorithms
recursion
identify-function
normal
+
–
64
votes
8
answers
204
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.7k
views
Kathleen
asked
Sep 21, 2014
Algorithms
gatecse-2007
algorithms
recursion
time-complexity
normal
+
–
26
votes
1
answer
205
GATE CSE 2007 | Question: 42
Consider the following C function: int f(int n) { static int r = 0; if (n <= 0) return 1; if (n > 3) { r = n; return f(n-2) + 2; } return f(n-1) + r; } What is the value of $f(5)$? $5$ $7$ $9$ $18$
Consider the following C function:int f(int n) { static int r = 0; if (n <= 0) return 1; if (n 3) { r = n; return f(n-2) + 2; } return f(n-1) + r; }What is the value of ...
Kathleen
10.4k
views
Kathleen
asked
Sep 21, 2014
Programming in C
gatecse-2007
programming
recursion
normal
+
–
28
votes
3
answers
206
GATE CSE 2004 | Question: 31, ISRO2008-40
Consider the following C function: int f(int n) { static int i = 1; if(n >= 5) return n; n = n+i; i++; return f(n); } The value returned by $f(1)$ is: $5$ $6$ $7$ $8$
Consider the following C function:int f(int n) { static int i = 1; if(n >= 5) return n; n = n+i; i++; return f(n); }The value returned by $f(1)$ is:$5$$6$$7$$8$
Kathleen
14.5k
views
Kathleen
asked
Sep 18, 2014
Programming in C
gatecse-2004
programming
programming-in-c
recursion
easy
isro2008
+
–
24
votes
2
answers
207
GATE CSE 2002 | Question: 11
The following recursive function in C is a solution to the Towers of Hanoi problem. void move(int n, char A, char B, char C) { if (......................) { move (.............................); printf("Move disk %d from pole %c to pole %c\n", n, A, C); move (.....................); } } Fill in the dotted parts of the solution.
The following recursive function in C is a solution to the Towers of Hanoi problem.void move(int n, char A, char B, char C) { if (......................) { move (...........
Kathleen
3.3k
views
Kathleen
asked
Sep 15, 2014
Programming in C
gatecse-2002
programming
recursion
descriptive
+
–
31
votes
2
answers
208
GATE CSE 2001 | Question: 13
Consider the following C program: void abc(char*s) { if(s[0]=='\0')return; abc(s+1); abc(s+1); printf("%c",s[0]); } main() { abc("123"); } What will be the output of the program? If $abc(s)$ is called ... string $s$ of length $n$ characters (not counting the null ('\0') character), how many characters will be printed by $abc(s)$?
Consider the following C program:void abc(char*s) { if(s[0]=='\0')return; abc(s+1); abc(s+1); printf("%c",s[0]); } main() { abc("123"); }What will be the output of the pr...
Kathleen
11.2k
views
Kathleen
asked
Sep 14, 2014
Programming in C
gatecse-2001
programming
recursion
normal
descriptive
+
–
26
votes
3
answers
209
GATE CSE 2000 | Question: 16
A recursive program to compute Fibonacci numbers is shown below. Assume you are also given an array $f [ 0\ldots m]$ with all elements initialized to $0.$ fib(n) { if (n > M) error (); if (n == 0) return 1; if (n = ... Write the box number and the corresponding contents in your answer book. What is the time complexity of the resulting program when computing $fib(n)?$
A recursive program to compute Fibonacci numbers is shown below. Assume you are also given an array $f [ 0\ldots m]$ with all elements initialized to $0.$fib(n) { if (n ...
Kathleen
4.8k
views
Kathleen
asked
Sep 14, 2014
Programming in C
gatecse-2000
algorithms
normal
descriptive
recursion
+
–
33
votes
8
answers
210
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.3k
views
Kathleen
asked
Sep 12, 2014
Programming in C
gate1991
programming
recursion
normal
numerical-answers
+
–
Page:
« prev
1
2
3
4
5
6
7
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register