Question: using JavaScript please!!! 1 Divide and Conquer Sum In the lectures, we've covered merge sort, which uses a divide-and-conquer ap- proach to sort an array
using JavaScript please!!!


1 Divide and Conquer Sum In the lectures, we've covered merge sort, which uses a divide-and-conquer ap- proach to sort an array of values. There are many more algorithms that take such an approach. Implement a function that computes the sum of an array of integers using divide and conquer. The function should have the following signature: function divideAndConquerSum(a); where a is the array. The recursive calls sum up the numbers in the base case, and "merge" the sums of the recursive calls otherwise. For example, the return value for the array a = [1,5,-1,4] is 9. To make it a bit more interesting, instead of splitting into two sub-arrays like in merge sort, I want you to split into three sub-arrays at each divide step. Submit your complete code, including a function that demonstrates that your implementation works with a few test inputs. Hint: Like in the implementation of merge sort, you may need a helper function that does the actual recursion. 2 Runtime Analysis What is the runtime of the algorithm that you implemented? Provide a re- currence relation for T(n) as we did for merge sort (you can ignore constant factors) and solve it as we did in the lectures. Give the final complexity. ocu ment describing your reasoning and the answers. rour reasoning is the most important part
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
