42 votes 42 votes Consider the following function: int unknown(int n){ int i, j, k=0; for (i=n/2; i<=n; i++) for (j=2; j<=n; j=j*2) k = k + n/2; return (k); } The return value of the function is $\Theta(n^2)$ $\Theta(n^2\log n)$ $\Theta(n^3)$ $\Theta(n^3\log n)$ Algorithms gatecse-2013 algorithms identify-function normal + – Arjun asked Sep 24, 2014 • edited Nov 2, 2017 by kenzou Arjun 30.0k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes The i loop will run for $n/2$ times while the j loop will run for $log n$ times . the value of k is incremented by n/2 everytime so the correct answer will be $(n^{2} log n) /4$ which is assymptotically ϴ$(n^{2} log n)$ Psy Duck answered Aug 3, 2023 Psy Duck comment Share Follow See all 0 reply Please log in or register to add a comment.