1,319 views

2 Answers

1 1 vote

It is exponential only.

recurrence functions will look like

f(n) = f(n-1) + g(n)

g(n) = f(n-1) + g(n/2)

When you are calling f(n), if you will draw a tree it will be at least n level tree on left most and  (log n) level tree on right most. 

if you want to take upper bound then take the maximum level possible and assume the tree to be complete binary tree in worst case so this way, there will be O(2^n) function call. In each fn call takes constant time so time complexity will be O(2^n) i.e exponential.

 

1 1 vote

f(x)=f(x-1)+g(x) -----------(i)

g(x)=f(x-1)+g(x/2)-----------(ii)

sub (ii) in (i) we get equation in terms of f(x)

f(x)=f(x-1)+f(x-1)+g(x/2)

=2f(x-1)+g(x/2).

g(x) is growing exponentially (approx)

g(1)=1,g(2)=3,g(3)=6,g(4)=14,g(5)=28,g(6)=56,118,216....its growth is approx exponentially.

f(x)=2*f(x-1)+$2^{n/2}$

=2[2f(x-2)+$2^{(n-1)/2}$]+$2^{n/2}$

=$2^{2}$f(x-2)+$2^{1/2}*2^{n/2}$+$2^{n/2}$

=..

.

=$2^{k}f(n-k)+2^{n/2}[2^{0/2}+2^{1/2}+2^{2/2}+.....2^{(k-1)/2}.]$

take n-k=1 and k=n-1 sub in the above equation.

=$2^{n-1}.1+2^{n/2}[0+2^{1/2}+2^{2/2}+....2^{n/2}]$   (Approx)

=$2^{n-1}+2^{n}*1.3$

=$2^{n}*[1.8]$ 

Hence Growth of f(x) should be exponential

Position:
Show:

Related questions

1 1 vote
1 1 answer
1.1k
1.1k views
Sajal Mallick asked Nov 28, 2023
1,112 views
Consider the problem that given a set Sof n integers and another integer x, whether or not there exist two elements in S whose sum is exactly x. What is the worst case ti...
0 0 votes
0 0 answers
525
525 views
Sajal Mallick asked Nov 28, 2023
525 views
What will be the complexity?Q. 8 Given a set $A=\left\{A_{1}, A_{2}, \ldots, A_{n}\right\}$ of $n$ activities with start and finish time ( $S i, f i$ ), $1 \leq i \leq n$...
0 0 votes
1 1 answer
594
594 views
NeelParekh asked Jul 27, 2023
594 views
If an array is split in the form of increasing and decreasing order then what is TC to find minimum element in the array?
0 0 votes
1 answers 1 answer
711
711 views
Sachdev aprajita asked May 23, 2019
711 views
Finding the running time of the following algorithm.$Procedure$ $A(n)$ $\textrm{ if (n}<=\textrm{2) then return 1 ;}$ $else$ $Return(A(\left \lceil \sqrt{n} \right ...