Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged recursion
0
votes
2
answers
121
MadeEasy Test Series: Programming & DS - Recursion
I am getting answer 13 but answer given is 17 !
I am getting answer 13 but answer given is 17 !
Prakhar Shukla 1
524
views
Prakhar Shukla 1
asked
Dec 8, 2017
Programming in C
made-easy-test-series
data-structures
programming-in-c
recursion
+
–
0
votes
0
answers
122
Time Complexity
hope(n){ if (n == 1) G(n) else F() + hope(n/2); } What is the time complexity for the given function, if the function G' and function F' take O(1) and O(n) unit of time respectively. My views: If we take the recursion in the form of " ... ;log n' times as well? Why can't the answer be O(nlogn) since F() (whose complexity is O(n)) is called 'log n' times?
hope(n){if (n == 1)G(n)elseF() + hope(n/2);}What is the time complexity for the given function, if the function ‘G’ and function ‘F’ take O(1) and O(n) unit of ti...
Warlock lord
360
views
Warlock lord
asked
Dec 4, 2017
Algorithms
time-complexity
algorithms
asymptotic-notation
recursion
+
–
0
votes
0
answers
123
[Algorithms] Tower of honoi
Can we solve Towers of honoi with DP? If yes,then what will be time and space complexity?
Can we solve Towers of honoi with DP? If yes,then what will be time and space complexity?
rahul sharma 5
560
views
rahul sharma 5
asked
Nov 26, 2017
Algorithms
recursion
towers-of-hanoi
programming
time-complexity
+
–
0
votes
1
answer
124
Recurssion problem.
What will be the output? for foo(4) 4332221234 4332221324 43222214 4332211223
What will be the output? for foo(4) 4332221234 4332221324 43222214 4332211223
JPranavc
402
views
JPranavc
asked
Nov 22, 2017
Programming in C
recursion
+
–
0
votes
1
answer
125
programming
how static affects in this program?
how static affects in this program?
chandra sai
361
views
chandra sai
asked
Nov 18, 2017
Programming in C
recursion
+
–
5
votes
2
answers
126
Time Complexity
Consider the following function Void func(int n){ Int k=n; Int i=0; for(;i<n;i++){ while(k>1){ k>>=1; } } What is the worst case time complexity of the function?
Consider the following functionVoid func(int n){Int k=n;Int i=0;for(;i<n;i++){while(k>1){k>>=1;}}What is the worst case time complexity of the function?
shaurya vardhan
1.6k
views
shaurya vardhan
asked
Nov 2, 2017
Algorithms
time-complexity
algorithms
asymptotic-notation
recursion
programming-in-c
+
–
4
votes
1
answer
127
Time Complexity
Consider the following code….. Search(int n){ if(n<2) then return; else{ s=0; for(i=1;i<=8;i++){ Search(n/2); } for(i=1;i<n*n;i++){ for(j=1;j<n;j=j*2){ s=s+i; } } } } Assume s is a global variable.Find the complexity of the given Search(n)?
Consider the following code…..Search(int n){if(n<2)then return; else{s=0;for(i=1;i<=8;i++){Search(n/2);}for(i=1;i<n*n;i++){for(j=1;j<n;j=j*2){s=s+i;}}}}Assume s is a gl...
shaurya vardhan
644
views
shaurya vardhan
asked
Nov 2, 2017
Algorithms
time-complexity
algorithms
asymptotic-notation
recursion
programming-in-c
+
–
3
votes
1
answer
128
Tower of Hanoi
In Tower of Hanoi problem, when we move 3 disk , it will rotate like Input : 3 Output : Disk 1 moved from A to C Disk 2 moved from A to B Disk 1 moved from C to B Disk 3 moved from A to C Disk 1 moved from B to A Disk 2 moved from ... www.cs.cmu.edu/~cburch/survey/recurse/hanoiex.html Some disk move I have shown here with recursion tree. Plz help me some moves of disk after this move
In Tower of Hanoi problem, when we move 3 disk , it will rotate likeInput : 3 Output : Disk 1 moved from A to C Disk 2 moved from A to B Disk 1 moved from C to B Disk 3 m...
srestha
2.5k
views
srestha
asked
Oct 26, 2017
DS
recursion
algorithms
towers-of-hanoi
+
–
2
votes
2
answers
129
c program
Consider the following code: int f(int num) { int result =0; if(num <= 1) return 1; else { for(i=num;i>=1;i--) result+=f(i/3); } return result; } Anyone plz explain this code line by line for input num=6????
Consider the following code:int f(int num){ int result =0; ...
Hira Thakur
1.5k
views
Hira Thakur
asked
Sep 27, 2017
Programming in C
programming-in-c
recursion
+
–
0
votes
1
answer
130
UGC NET CSE | December 2009 | Part 2 | Question: 11
Recursive functions are executed in a (A) First in first out-order (B) Last in first out-order (C) Parallel fashion (D) Load balancing
Recursive functions are executed in a(A) First in first out-order(B) Last in first out-order(C) Parallel fashion(D) Load balancing
rishu_darkshadow
1.8k
views
rishu_darkshadow
asked
Sep 16, 2017
Algorithms
ugcnetcse-dec2009-paper2
algorithms
recursion
+
–
2
votes
0
answers
131
time complexity
What is the time complexity of the following code snippet? Assume x is a global variable and “statement” takes O(n) time?
What is the time complexity of the following code snippet? Assume x is a global variable and “statement” takes O(n) time?
Warlock lord
824
views
Warlock lord
asked
Sep 11, 2017
Algorithms
time-complexity
algorithms
asymptotic-notation
recursion
+
–
0
votes
2
answers
132
Please explain this Q
Consider the following C program int f1(int n) { if(n == 0 || n == 1) return n; else return (2*f1(n-1) + 3*f1(n-2)); } Consider the program given in above question, f1(8) and f2(8) return the values A 1661 and 1640 B 59 and 59 C 1640 and 1640 D 1640 and 1661
Consider the following C programint f1(int n) { if(n == 0 || n == 1) return n; else return (2*f1(n-1) + 3*f1(n-2)); }Consider the program given in above question, f1(8) a...
kallu singh
486
views
kallu singh
asked
Aug 12, 2017
Programming in C
programming
programming-in-c
recursion
+
–
1
votes
1
answer
133
algorithm
A binary search algorithm is implemented using recurrsion then what is the space and time complexity?
A binary search algorithm is implemented using recurrsionthen what is the space and time complexity?
A_i_$_h
394
views
A_i_$_h
asked
Jul 24, 2017
Algorithms
binary-search
recursion
space-complexity
time-complexity
+
–
1
votes
1
answer
134
recursion
gabbar
1.7k
views
gabbar
asked
Jul 14, 2017
Programming in C
recursion
programming-in-c
+
–
0
votes
2
answers
135
How do I solve this recursion?
What is the value of F(n, m)? Function F(n, m : integer) : integer; begin if(n <= 0) or (m <= 0) then F:=1 else F := F(n-1, m) + F(n, m-1); end;
What is the value of F(n, m)?Function F(n, m : integer) : integer; begin if(n <= 0) or (m <= 0) then F:=1 else F := F(n-1, m) + F(n, m-1); end;
Akash Mishra
546
views
Akash Mishra
asked
Jul 7, 2017
Programming in C
recursion
programming
data-structures
+
–
2
votes
0
answers
136
doubt
$T(n) = 1/n\sum T(I) + 1.$ Sum ranges from I=1 to i=n-1
$T(n) = 1/n\sum T(I) + 1.$Sum ranges fromI=1 to i=n-1
Sachi Saxena 11
198
views
Sachi Saxena 11
asked
Jul 6, 2017
Algorithms
recurrence-relation
recursion
+
–
3
votes
2
answers
137
Practice book
Question no 11.
Question no 11.
Arnab Bhadra
583
views
Arnab Bhadra
asked
Jun 27, 2017
DS
recursion
+
–
3
votes
3
answers
138
Recursive function
int fun(int n) { int s=0,i; if(n<=1) return 1; for(i=1; i*i<n; i++) s+=n; return fun(n/4)+fun(n/4)+s; } what will be the time complexity, returning value and no. of recursive calls of the above-given code?
int fun(int n) { int s=0,i; if(n<=1) return 1; for(i=1; i*i<n; i++) s+=n; return fun(n/4)+fun(n/4)+s; } what will be the time complexity, returning value and no. of recur...
Diksha Aswal
1.0k
views
Diksha Aswal
asked
Jun 27, 2017
Algorithms
algorithms
time-complexity
recursion
+
–
1
votes
3
answers
139
Predict the output
#include <stdio.h> void f(int); int main() { int a=4; f(a); return 0; } void f(int n) { if(n>0) { f(--n); printf("%d", n); f(--n); } } Explain how function calls take place
#include <stdio.h void f(int); int main() { int a=4; f(a); return 0; } void f(int n) { if(n>0) { f( n); printf("%d", n); f( n); } }Explain how function calls take place
just_bhavana
1.2k
views
just_bhavana
asked
Jun 23, 2017
Programming in C
programming-in-c
recursion
+
–
0
votes
0
answers
140
Tower of Hanoi
how to Write a program in C which implements tower of Hanoi using recursion? and please explain lines of code if possible. It 'll be a great help.
how to Write a program in C which implements tower of Hanoi using recursion? and please explain lines of code if possible.It 'll be a great help.
iarnav
638
views
iarnav
asked
May 27, 2017
Algorithms
recursion
towers-of-hanoi
+
–
0
votes
5
answers
141
Gate Algo & ds
#include <stdio.h> int f(int n) { if(n ≤ 1) return 1; if(n%2 = = 0) return f(n/2); return f(n/2) + f(n/2+1); } int main() { printf("%d", f(11)); return 0; } (a) Stack Overflow (b) 3 (c) 4 (d) 5
#include <stdio.h int f(int n) { if(n ≤ 1) return 1; if(n%2 = = 0) return f(n/2); return f(n/2) + f(n/2+1); } int main() { printf("%d", f(11)); return 0; }(a) Stack Ove...
Pranav Madhani
1.2k
views
Pranav Madhani
asked
May 26, 2017
Algorithms
algorithms
recursion
+
–
1
votes
2
answers
142
Gate Sample Question
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: (a) 5 (b) 6 (c) 7 (d) 8 need solution with explaination
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:(a) 5 (b) 6(c) 7 (d) 8 need solution with explaination...
Pranav Madhani
1.9k
views
Pranav Madhani
asked
May 26, 2017
Algorithms
geeksforgeeks-test-series
algorithms
recursion
+
–
1
votes
2
answers
143
Gate Sample Question
#include<stdio.h> void crazy(int n, int a, int b) { if (n ≤ 0) return; crazy(n-1, a, b + n); printf("%d %d %d\n", n, a, b); crazy(n-1, b, a + n); } int main() { crazy(3, 4, 5); 5 return 0; } (a) 1 4 10 (b) 3 4 5 2 4 8 1 4 10 1 8 6 2 4 8 3 4 ... 2 5 7 2 5 7 1 7 7 1 7 7 (c) 1 4 10 (d) 3 4 5 2 4 8 1 5 9 1 8 6 2 5 7 3 4 5 1 7 7 please need solution with explaination
#include<stdio.h>void crazy(int n, int a, int b){if (n ≤ 0) return;crazy(n-1, a, b + n);printf("%d %d %d\n", n, a, b);crazy(n-1, b, a + n);}int main(){crazy(3, 4, 5);5r...
Pranav Madhani
785
views
Pranav Madhani
asked
May 26, 2017
Algorithms
geeksforgeeks-test-series
algorithms
data-structures
recursion
+
–
0
votes
1
answer
144
Gate Sample Practise Questions
#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; } (a) -9 (b) 5 (c) 15 (d) 19 Need explanation stepwise for solution
#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...
Pranav Madhani
497
views
Pranav Madhani
asked
May 26, 2017
Algorithms
geeksforgeeks-test-series
recursion
identify-function
+
–
0
votes
1
answer
145
Placing rooks in nXn chess board
Write a recursive backtracking solution for placing $3$ rooks in $6^*6$ chess board. Naive backtracking. Try using bitmask to speed it up.
Write a recursive backtracking solution for placing $3$ rooks in $6^*6$ chess board.Naive backtracking.Try using bitmask to speed it up.
dd
1.1k
views
dd
asked
May 4, 2017
Algorithms
non-gate
recursion
combinatory
+
–
2
votes
4
answers
146
recursion in c
output of program: void function(int); void main() { function(3); } void function(int num){ if(num>0) { function(--num); printf("%d",num); function(--num); } } will the argument num value be retained at all recursion levels?
output of program:void function(int); void main() { function(3); } void function(int num){ if(num>0) { function( num); printf("%d",num); function( num); } }will the argum...
gate_forum
1.4k
views
gate_forum
asked
Mar 16, 2017
Programming in C
programming-in-c
recursion
+
–
104
votes
7
answers
147
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.2k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming-in-c
programming
normal
recursion
+
–
47
votes
11
answers
148
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.1k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming
normal
tricky
recursion
+
–
0
votes
1
answer
149
Test by Bikram | Mock GATE | Test 1 | Question: 45
How many times $fibon$\left ( 3 \right )$ is called during invocation of $fibon$ $\left ( 6 \right )$? $fibon(x) = fibon(x-1) + fibon(x-2)$ $fibon(0) = 1$ $fibon(1) = 1$ 3 4 5 6
How many times $fibon$$\left ( 3 \right )$ is called during invocation of $fibon$ $\left ( 6 \right )$?$fibon(x) = fibon(x-1) + fibon(x-2)$$fibon(0) = 1$$fibon(1) = 1$345...
Bikram
322
views
Bikram
asked
Jan 16, 2017
GATE
tbb-mockgate-1
algorithms
recursion
+
–
0
votes
1
answer
150
LCS problem
firki lama
460
views
firki lama
asked
Jan 8, 2017
Algorithms
recursion
test-series
+
–
Page:
« prev
1
2
3
4
5
6
7
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register