in Algorithms retagged by
448 views
1 vote
1 vote

 

in Algorithms retagged by
448 views

4 Comments

Take any value of x and see how many times fun1 is called. y doesn't matter here.

If x=4 then fun1(4,y) --> fun1(3,4+y) -->fun1(2,3+y)--->fun1(1,2+y)--->fun1(0,1+y)

5 times.

Similarly for any value of x fun1 will be called for x+1 times and in each call only constant work is done like comparison. So O(c*(x+1))=O(x)
0
0
whatever the size of X you take the  recursion stack size or depth of the recursion tree is also X

try it !
0
0
Ok bhai thnxx :)
0
0

1 Answer

1 vote
1 vote
T(n)=T(n-1)+1

complexity will be 1+1+1+1.....n times

=O(n)

so B is the answer

Related questions

3 votes
3 votes
1 answer
1
1 vote
1 vote
0 answers
2
0 votes
0 votes
1 answer
4