search
Log In

Recent questions tagged recursion

0 votes
1 answer
1
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 in Theory of Computation Lakshman Patel RJIT 36 views
1 vote
3 answers
2
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 in DS jothee 277 views
0 votes
1 answer
3
#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 461 views
3 votes
3 answers
4
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 478 views
5 votes
1 answer
6
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 234 views
0 votes
1 answer
7
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 163 views
2 votes
1 answer
8
#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 676 views
3 votes
2 answers
9
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 2.3k views
2 votes
1 answer
10
1 vote
1 answer
11
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 595 views
1 vote
2 answers
12
What is Head recursion and Tail Recursion??
asked Oct 22, 2018 in Programming Lakshman Patel RJIT 148 views
2 votes
1 answer
13
asked Sep 2, 2018 in Programming nag.swarna 153 views
1 vote
2 answers
14
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 309 views
0 votes
0 answers
15
#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 455 views
2 votes
2 answers
16
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 189 views
2 votes
2 answers
17
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 302 views
1 vote
1 answer
18
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 380 views
0 votes
1 answer
19
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 319 views
1 vote
2 answers
20
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 647 views
1 vote
0 answers
21
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 166 views
7 votes
3 answers
22
Why is recursive equation of following code $T(n)=T(n/2)+O(1)$, not $T(n)=8*T(n/2)+O(1)$? int x=0; int A(n) { if(n==1) return 1; else { X+=8A(n/2)+n^3; } return X; }
asked May 29, 2018 in Algorithms bts 472 views
0 votes
1 answer
23
int lcs_length(char * A, char * B) { if (*A == '\0' || *B == '\0') return 0; else if (*A == *B) return 1 + lcs_length(A+1, B+1); else return max(lcs_length(A+1,B), lcs_length(A,B+1)); } what is worst case time complexity of $\text{lcs_length}$ if size of $A$ is $m$ and size of $B$ is $n$? O($2^{m+n}$) O($2^{n}$) O($2^{mn}$) O($2^{max(m,n)}$) none of these
asked Apr 28, 2018 in Algorithms hacker16 130 views
0 votes
0 answers
24
What is the max height of recursion tree of recurrence $c(100,50)$? here, the recursive function is defined as $c(n,k) = c(n-1,k-1) + c(n,k-1)$ terminating condition $c(n,n) = 1, c(n,0) = 1$.
asked Apr 28, 2018 in Algorithms hacker16 199 views
1 vote
1 answer
25
Let $P$ be a procedure that for some inputs calls itself (i.e. is recursive). If $P$ is guaranteed to terminate, which of the following statement(s) must be true? $P$ has a local variable $P$ has an execution path where it does not call itself $P$ either refers to a global variable or has at least one parameter I only II only III only II and III only
asked Apr 22, 2018 in Programming Arjun 728 views
0 votes
1 answer
26
What data structure would you most likely see in a non-recursive implementation of a recursive algorithm? Linked List Stack Queue Tree please explain also
asked Mar 23, 2018 in Programming Moin Mukhtar 318 views
0 votes
0 answers
27
Can anyone check this program? I got some warning. #include<stdio.h> #include<stdlib.h> void func(struct node *); struct node { int data; struct node *next; }; int main() { struct node *head=(struct node *)malloc(sizeof(struct node)); struct node *temp=(struct node *)malloc(sizeof(struct ... func(head); return 0; } void func(struct node *p) { if(p) { printf("\n%d",p->data); func(p->next); } }
asked Mar 6, 2018 in Programming Ahsanul Hoque 166 views
...