Question: (15 pts) Consider the following recursive sum_first_ N function. This function takes an array (arr) and an integer (N) and it calculates the sum of

(15 pts) Consider the following recursive sum_first_ N function. This function takes an array (arr) and an integer (N) and it calculates the sum of first N values the array 'arr'. A sample main function that calls sum_first_N is also provide (a) (15 pts) sum_first_N is not tail-recursive. Rewrite the sum_first_N using tail-recursion. Name your function "sum_first_N_tail". (b) (5pts) Rewrite sum_first_ N without using recursion (i.e., using a while loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
