3,289 views
2 2 votes

Running time of an algorithm $T(n),$ where $n$ is input size is given by

$T(n) = \begin{cases} 8 T(n/2) + qn, & \textsf{ if } n>1 \\  p, & \textsf{ if } n=1 \end{cases}$ where $p$ and $q$ are constants. $T(n)$ is 

  1. $\Theta(n^2)$
  2. $\Theta(n^n)$
  3. $\Theta(n^3)$
  4. $\Theta(n)$ 

1 Answer

Best answer
4 4 votes
Case 1 of master theorem as

$f(n) = O\left(n^{\log_b a -\epsilon} \right ) \\= O\left(n^{\log_2 8 -\epsilon }\right) \\= O\left(n^{3 -\epsilon} \right)$

is true for any $ 0 < \epsilon \leq 2$.

Now, the complexity is $\Theta\left(n^{ \log_b a }\right) = \Theta \left(n^3\right)$.
• selected by
Position:
Show:

Related questions

2 2 votes
2 2 answers
10.2k
10.2k views
pradeepchaudhary asked Jul 14, 2018
10,157 views
Q.6 The time complexity of an algorithm T(n), where n is the input size, is given by— T(n)= T(n-1) + 1/n, if n>1 = 1, otherwise.The order of the algorithm is—(a)...
4 4 votes
5 answers 5 answers
23.5k
23.5k views
worst_engineer asked Oct 7, 2015
23,493 views
The running time of an algorithm is given by\[T(n)=T(n-1)+T(n-2)-T(n-3) \text {, if } n \geqslant 3\]n, otherwise.The order is :n$\log n$$\mathrm{n}^{n}$$n^{2}$
1 1 vote
1 1 answer
665
665 views
Soumyashree asked Nov 21, 2015
665 views
T(n) = T(n-1)+ 1/n if n>1 =1 otherwiseThe order of the algorithm is
0 0 votes
1 1 answer
730
730 views
syedasafoora asked Nov 8, 2023
730 views
Consider the following algorithm for Build-Max-heap and the given array A=[ 47,96, 35, 54, 77, 65, 83]. Run this algorithm on the given array and redraw the heap and the ...