Multiple choice time complexity of function What is time complexity of fun()? int fun(int n) { int count = 0; for (int i = 0; i < n; i++) for (int j = i; j > 0; j--) count = count + 1; return count; } $\theta(n^2)$ $\theta(nlogn)$ $\theta(n)$ $\theta(logn)^2$ Reveal answer Fill a bubble to check yourself A Correct answer Full explanation
Multiple choice time complexity of function Consider the following two functions. What are time complexities of the functions? int fun1(int n) { if (n <= 1) return n; return 2*fun1(n-1); } int fun2(int n) { if (n <= 1) return n; return fun2(n-1) + fun2(n-1); } $O(2^n)$ for both fun1() and fun2() $O(n)$ for fun1() and $O(2^n)$ for fun2() $O(2^n)$ for fun1() and $O(n)$ for fun2() $O(n)$ for both fun1() and fun2() Reveal answer Fill a bubble to check yourself B Correct answer Full explanation