2. R(N) is the running time of strange_sum when called on a List of length N. Since this is recursive code, your answer to iii should include a diagram of the recursion tree. a. Answer for li being an...


2. R(N) is the running time of strange_sum when called on a List of length N. Since this is<br>recursive code, your answer to iii should include a diagram of the recursion tree.<br>a. Answer for li being an ArrayList<br>b. Answer for li being a LinkedList<br>static int strange_sum(List<E> li) {<br>return strange_sum_helper(li, 0, li.size() - 1);<br>static int strange_sum_helper (List<E> arr, int left, int right) {<br>if (right - left < 0) return 0;<br>else if (right<br>else {<br>int mid = (left + right) / 2;<br>return strange_sum_helper(arr, left, mid)<br>left<br>0) return arr.get(left);<br>==<br>+ strange_sum_helper(arr, mid + 1, right);<br>}<br>}<br>

Extracted text: 2. R(N) is the running time of strange_sum when called on a List of length N. Since this is recursive code, your answer to iii should include a diagram of the recursion tree. a. Answer for li being an ArrayList b. Answer for li being a LinkedList static int strange_sum(List li) { return strange_sum_helper(li, 0, li.size() - 1); static int strange_sum_helper (List arr, int left, int right) { if (right - left < 0)="" return="" 0;="" else="" if="" (right="" else="" {="" int="" mid="(left" +="" right)="" 2;="" return="" strange_sum_helper(arr,="" left,="" mid)="" left="" 0)="" return="" arr.get(left);="=" +="" strange_sum_helper(arr,="" mid="" +="" 1,="" right);="" }="">
For each problem, please provide<br>i.<br>Describe the worst-case input (the input that would cause the largest running time)<br>Summation used to calculate number of steps for the worst case<br>Explanation of how the code relates to the summation<br>ii.<br>iii.<br>a. (loops require discussing number of iterations and steps per iteration)<br>b. (recursion requires a diagram)<br>A O bound<br>iv.<br>

Extracted text: For each problem, please provide i. Describe the worst-case input (the input that would cause the largest running time) Summation used to calculate number of steps for the worst case Explanation of how the code relates to the summation ii. iii. a. (loops require discussing number of iterations and steps per iteration) b. (recursion requires a diagram) A O bound iv.

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here