Dark Mode

179 views

3 votes

**Answer: C**

When

$a$ = 1, $b$ will run $log(1)$ times,

$a$ = 2, $b$ will run $log(2)$ times,

$a$ = 3, $b$ will run $log(3)$ times,

$...$

$a$ = $n$, $b$ will run $log(n)$ times.

Total time taken = $log(1) + log(2) + log(3) + … + log(n)$

= $log(1*2*3*...*n)$ $=$ $log(n!)$

And when $n$ is large according to Stirling's approximation

$log(n!) = O(nlogn)$