edited by
2,126 views
1 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$

1 Answer

1 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:
Position:
Show:

Related questions

0 0 votes
1 1 answer
1.3k
1.3k views
admin asked Apr 1, 2020
1,338 views
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. ...
1 1 vote
1 1 answer
767
767 views
admin asked Apr 1, 2020
767 views
The solution of the recurrence relation$a_{r} = a_{r-1} + 2a_{r-2}$ with $a_{0} = 2,a_{1} = 7$ is$a_{r} = (3)^{r} + (1)^{r}$$2a_{r} = (2)^{r}/3 – (1)^{r}$$a_{r} = 3^{r+1}...
2 2 votes
3 3 answers
1.3k
1.3k views
admin asked Apr 1, 2020
1,310 views
Consider the following C code segment:int Ls Prime(n) { int i,n; for(i=2;i<=sqrt(n);i++) if(n%i ==0) { printf(“NOT Prime.\n”); retu...
1 1 vote
3 3 answers
1.5k
1.5k views
admin asked Apr 1, 2020
1,472 views
An algorithm is made up of two modules $M1$ and $M2.$ If order of $M1$ is $f(n)$ and $M2$ is $g(n)$ then he order of algorithm is$max(f(n),g(n))$$min(f(n),g(n))$$f(n) + g...