Problem 3. How many lines, as a function of n (in O.) form), does the following...
Can I please get help with this question? Problem 3. How many lines, as a function of n (in 0(.) form), does the following program print? Write a recurrence and solve it. You may assume n is a power of 2. function f(n) { If (n>1) { print.line ("still going");/ f(n/2); f(n/2); }
Consider the following pseudocode: f(int n, int d) { println(space(d) + "n=" + n + " begins"); if (n > 1) { f(n/2, d+1); println(space(d+1) + "hi"); f(n/2, d+1); } println(space(d) + "n=" + n + " ends"); } where println(s) prints the string s on its own line, space(d) is a string of d spaces, and the + in the println means string concatenation. For example, if n=4 and d=2, the commands println(space(d) + "n=" + n + "...
How much time does the following "algorithm" require as a function Problem 4.1. of n? for i 1 to n do for j 1 to n do for k 1 to n3 do Express your answer in 6 notation in the simplest possible form. You may consider that each individual instruction (including loop control) is elementary
pleas answer asap 3. (20 points) Algorithm Analysis and Recurrence There is a mystery function called Mystery(n) and the pseudocode of the algorithm own as below. Assume that n 3* for some positive integer k21. Mystery (n) if n<4 3 for i1 to 9 5 for i-1 to n 2 return 1 Mystery (n/3) Print "hello" 6 (1) (5 points) Please analyze the worst-case asymptotic execution time of this algorithm. Express the execution time as a function of the input...
Solve exactly using the iteration method the following recurrence T(n) = 2T(n/2) + 6n, with T(8) = 12. You may assume that n is a power of two. Please explain your answer. (a) (20 points) Solve exactly using the iteration method the following recurrence T(n) - 2T(n/2) + 6n, with T(8)-12. You may assume that n is a power of two.
2. Consider the following functions. For each of them, determine how many times is ‘hey’ printed in terms of the input n. You should first write down a recurrence and then solve it using the recursion tree method. That means you should write down the first few levels of the recursion tree, specify the pattern, and then solve. (a) def fun(n) { if (n > 1) { print( ‘hi’ ‘hi’ ‘hi’ ) fun(n/4) fun(n/4) fun(n/4) }} (b) def fun(n) {...
Problem 3. (20 points) Define a relation among the functions that map from N to R+ as follows: f(n) g(n) iff f (n) is o(g(n)) i.e. f(n) is O(gfn) but g(n) is not O(f(n)). Order the following functions according to <assuming e is a real constant, 0<E<1. Provide justifcations for your answer. (a) n log n, ( e), and (h) (1/3)" ni+e, (e) (n Problem 4. (15 points) Solve the following recurrence equations and give the solution in θ notation;...
How many critical numbers does the following function have? f(x) = x²e-32 1 3 N Infinitely many 0
Consider the problem of computing the power function pow(n,x) = n^x using only multiplications. The first approach is to perform x multiplications ($n \cdot n \cdot n \cdot \ldots \cdot n$, x times). Find a better, recursive algorithm to solve this problem (by better, we mean one that uses fewer than $x$ multiplications). Write down the pseudocode for this new function, and then analyze the runtime of that recursive program by first writing out the recurrence relation $T(n, x)$ that...
Consider the problem of computing the power function pow(n,x) = n^x using only multiplications. The first approach is to perform x multiplications ($n \cdot n \cdot n \cdot \ldots \cdot n$, x times). Find a better, recursive algorithm to solve this problem (by better, we mean one that uses fewer than $x$ multiplications). Write down the pseudocode for this new function, and then analyze the runtime of that recursive program by first writing out the recurrence relation $T(n, x)$ that...