I am given an array of integers, and trying to define a recursive method sum(int[] A,int s, int e) to calculate the sum of array A, where s and e are starting index and ending index. I want to test it with a given array int[] A= {3,5,8,9,10}.
I am confused on how to do this but here is what I have so far (I am even a little confused on the code here because my buddy helped me write it, a little explanation would help a lot!):
public static int sum(int[]A,int s,int e) {
if (s==e)
return A[e];
else
return A[5] + sum(A,s+1,e);
return A[s] ...notreturn A[5] .... Other than that, what exactly are you confused about?