Question: Part 4: Algorithm Analysis 1. Given the following algorithms below, give a fin) such that R(n) E o(f(n)) where R(n) is the running time for
Part 4: Algorithm Analysis 1. Given the following algorithms below, give a fin) such that R(n) E o(f(n)) where R(n) is the running time for input of size n. For each problem, you must provide justification. Proper justification must include i) a written explanation and ii) a diagram and/or mathematical reasoning. c. R(n) is the running time of strange_sumA in terms of n, the length of arr int strange sumA(int] arr) if (arr.length1) ) else return arr[0]; int newien .. arr . length/2; int arrLeft new int[newlen] int arrRight new int[newlen] for (int i-0 i newlen; i++) arrLeft [ i ] arr [ i ] ; for i-newlen; icarr.length-1; ++) { (int arrRight[i-newlen] arr[i]; return strange_sumA (arrLeft) strange sumA (arrRight); d. R(n) is the running time of strange_sumB in terms of n, the length of arr. (If it makes the analysis easier, you may assume that the length of arr is a power of 2). int strange sumB(intl arr, int left, int right) if (right left1) ( return arrleft]: else return strange sumB (arr, left, right/2) strange sumB (arr, right/2, right) e. strangeSumA and strangeSumB both sum the elements of an array. Why do strangeSumA and strangeSumB have different asymptotic running times
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
