search
Log In

Recent questions tagged recursion

2 votes
2 answers
1
Consider the following $\text{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 $\textrm{SomeFunction(15, 255)}$ is __________
asked Feb 18 in Programming Arjun 476 views
4 votes
2 answers
2
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, y-q, q) + foo(x-q, y, q); } int main( ) { int r = foo(15, 15, 10); printf(β€œ%d”, r); return 0; } The output of the program upon execution is _________
asked Feb 18 in Programming Arjun 480 views
0 votes
2 answers
3
Consider the following program. Assume that $x$ and $y$ are integers. f(x, y) { if (y != 0) return (x * f(x,y-1)); else return 1; } What is $f(6,3)?$ $243$ $729$ $125$ $216$
asked Jan 29 in Algorithms soujanyareddy13 72 views
0 votes
1 answer
4
What is the time complexity of the following recursive function? int ComputFun(int n) { if(n<=2) return 1; else return (ComputFun(floor(sqrt(n)))+n); } $\Theta(n)$ $\Theta(\log n)$ $\Theta(n\log n)$ $\Theta(\log \log n)$
asked Dec 9, 2020 in Unknown Category gatecse 31 views
0 votes
1 answer
5
Choose the correct statements. A total recursive function is also a partial recursive function A partial recursive function is also a total recursive function A partial recursive function is also a primitive recursive function None of the above
asked Apr 1, 2020 in Theory of Computation Lakshman Patel RJIT 189 views
1 vote
3 answers
6
A recursive function $h$, is defined as follows: $\begin{array} {} h(m) & =k, \text{if } m=0 \\ &=1, \text{if } m=1 \\ &= 2 h(m-1)+4h(m-2), \text{if } m \geq 2 \end{array}$ If the value of $h(4)$ is $88$ then the value of $k$ is: $0$ $1$ $2$ $-1$
asked Mar 24, 2020 in DS jothee 398 views
0 votes
1 answer
7
#include<iostream> using namespace std; int i=0; void a() { i+=1; cout<<i<< ".hello"<<endl; a(); } int main() { a(); } For this above code the output is only upto β†’ 64891.Hello Does this mean that that the stack can hold only 64891 recursive calls? (I am using dev c++)
asked Jun 2, 2019 in Programming Hirak 658 views
3 votes
3 answers
8
Consider the following function: void madeeasy (int n) { if (n < 0) return; else { printf(n); madeeasy (- -n); madeeasy (n - -); printf(n); } } The sum of all values printed by madeeasy (5)_______ (I am getting -12 but given answer is 52)
asked Jan 30, 2019 in Programming newdreamz a1-z0 617 views
5 votes
1 answer
10
Consider the function: int fun(int n) { if (n==4) return n; else return 2*fun(n+1); } A MOD-16 ripple counter is holding the count $(1001)_2.$ What will be the count after "$(\text{fun}(2)+15)_{10}$" clock pulses? $(1000)_2$ $(1010)_2$ $(1011)_2$ $(1101)_2$
asked Dec 27, 2018 in Digital Logic Ruturaj Mohanty 335 views
0 votes
1 answer
11
Consider the two given functions: int fun1(int x, int y) { if (y==0) return 0; return (x+fun2(x, y-1)); } int fun2(int x, int y) { if (x==0) return y; return fun2(x-1, x+y); } What will be the value returned by $\text{fun1}(4, 4)$ ____
asked Dec 27, 2018 in Algorithms Ruturaj Mohanty 228 views
2 votes
1 answer
12
#include <stdio.h> void print(int n, int j) { if (j >= n) return; if (n-j > 0 && n-j >= j) printf("%d %dn", j, n-j); print(n, j+1); } int main() { int n = 8; print(n, 1); } (A) 1 7 2 6 3 5 4 4 4 4 (B) 1 7 2 6 3 5 4 4 (C) 1 7 2 6 3 5 (D) 1 2 3 4 5 6 7 8 Answer is B. anyone can explain how?
asked Dec 11, 2018 in Algorithms Gangani_Son 1.3k views
3 votes
2 answers
13
T(n) = sqrt(n) * T(sqrt(n)) + n Given solution is O(log log n). But my solution is O(n log log n). 'wolframalpha'' shows the answer same as mine. You can find the solution here. Can anyone confirm the solution and provide an explantion?
asked Nov 22, 2018 in Algorithms gmrishikumar 3.8k views
2 votes
1 answer
14
1 vote
1 answer
15
Does Heap Allocation support both recursion and dynamic memory allocation? Because,a stack can be implemented using dynamic memory allocation.Please correct me. Test Series answer shows only dynamic memory allocation
asked Nov 3, 2018 in Compiler Design sripo 927 views
1 vote
2 answers
16
What is Head recursion and Tail Recursion??
asked Oct 22, 2018 in Programming Lakshman Patel RJIT 180 views
2 votes
1 answer
17
asked Sep 2, 2018 in Programming nag.swarna 201 views
1 vote
2 answers
18
int zap(int n) { if (n<=1) then zap =1; else zap = zap(n-3)+zap(n-1); } then the call zap(6) gives the values of zap Give the proper explanation
asked Aug 28, 2018 in Programming shivam sharma 5 478 views
0 votes
0 answers
19
#include <stdio.h> void fun(int); typedef int (*pf) (int ,int ); int proc(pf, int ,int); int main() { int a = 3; fun(a); return 0; } void fun(int n) { if (n>0) { fun(--n); printf("%d,", n); fun(--n); } }
asked Aug 27, 2018 in Programming shivam sharma 5 732 views
2 votes
2 answers
20
How to trace the below program? p and q are the starting address of two different linked list struct node*Do(struct node*p,struct node*q){ struct node*ps,*qs; if(!p){ return(q); } else if(!q){ return(p); } else{ ps=p->link; qs=q->link; p->link=q; q->link=Do(ps,qs); return(p); } }
asked Aug 3, 2018 in Programming rishabhgupta12 256 views
2 votes
2 answers
21
int f (int n){ if (n==0) return 0; if(n==1) return 1; else return f(n-1)+f(n-2); } Find the upper bound and lower bound to the number of function calls for input size 'n'?
asked Jul 8, 2018 in Programming parasghai28 406 views
1 vote
1 answer
22
void ab() { auto int a; static int s= 5; a = ++s; printf("%d%d",a,s); if(a<= 7) ab(); printf("%d%d",a,s); } void main() { ab(); } According to me answer should be- 667788887766 but the answer is - 667788887868. Please explain
asked Jul 8, 2018 in Programming parasghai28 468 views
0 votes
1 answer
23
Consider the following program written in pseudo-code. Assume that x and y are integers. Count (x, y) { if (y !=2 ) { 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 ... =========================================== My answer is 10220 and I just need someone to verify if it's correct.
asked Jun 28, 2018 in Programming iarnav 377 views
2 votes
2 answers
24
To remove recursion from a program we have to use which of the following data structure? array stack queue list
asked Jun 18, 2018 in DS eyeamgj 988 views
1 vote
0 answers
25
What will be the time complexity of the following algorithm ? A(n){ if(n<=1) return 1; for(i=1;i<n;i++){ for(j=0;j<3;j++){ A(n-1) } } }
asked Jun 17, 2018 in Algorithms kartikeya2812 187 views
...