retagged by
1,017 views

1 Answer

1 votes
1 votes
i loop will go upto $logn$ times...................i

for j     p value will be $\left ( n-1 \right )$

Now, k depends on p

k will go like $3^{1}+3^{2}+3^{3}+3^{4}+...............$

$=3^{k}-1$=$=3^{logn}-1=O\left ( n \right )$................ii

So,from i and ii complexity will be $O\left ( nlogn \right )$

Related questions

0 votes
0 votes
0 answers
2