in Algorithms edited by
1,272 views
1 vote
1 vote

The running time of an algorithm $T(n),$ where $’n’$ is the input size , is given by

$T(n) = 8T(n/2) + qn,$ if $n>1$

$ = p,$ if $n = 1$

Where $p,q$ are constants. The order of this algorithm is

  1. $n^{2}$
  2. $n^{n}$
  3. $n^{3}$
  4. $n$
in Algorithms edited by
by
1.3k views

4 Comments

Use back substitution.
0
0
Manually means by using the tree approach. Just as we do forr merge sort.
0
0
bro, actually we are not dividing the input size of n into 8 parts.

here ,  a function takes an input of size of  n , and by definition of the the above  recur. relation  it calls 8  function of  its type but here with size  = n/2.

and, subsequently each of these call 8 funtion of size= n/4.

and  for every level calling cost = (n).

hope yu understand.
0
0

1 Answer

1 vote
1 vote

We can directly apply master’s theorem on this to get T(n).

T(n) = aT(n/b)+ f(n) a>=1, b>1
and
If f(n) is Ɵ(n^d) d>=0

then,
if a<b^d then T(n) = Ɵ(n^d)
elif a==b^d then T(n) = Ɵ(n^d logn)
elif a>b^d then T(n) = Ɵ(n^(logab)

Here,

a = 8; b = 2; d = 1

and, a>$b^{d}$

Therefore,

T(n) = Ɵ(n$\log_{a} b$) = Ɵ(n$\log_{2} 8$) = Ɵ($n^{3}$)

Answer:

Related questions