Question: Java and Algorithm problem. Please, show the stepss The balance index of an array of integers is an index such that the sum of elements
Java and Algorithm problem. Please, show the stepss

The balance index of an array of integers is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes. The formal definition is: The integer k is an balance index of a sequence of integers S[0]; S[1];...; S[n - 1] if and only if 0 lessthanorequalto k and sigma_i = 0^k - 1 S[i] = sigma_i = k + 1^n - 1 S[i]. Assume the sum of zero elements is equal to zero. For example, in a sequence S: S[0] = -5; S[1] =3; S[2] = 7; S[3] = -8; S[4] = -2; S[5]= 5; S[6] =2 3 is a balance index, because: S[0] + S[1] + S[2] = S[4] + S[5] + S[6] 6 is also a balance index, because: S[0] + S[1] + S[2] + S[3] + S[4] + S[5] = 0 And the sum of zero elements is zero. Note that the index 7 is not a balance index - because it is not a valid index of sequence S. Implement an efficient function in Java int ballndex(int S[], int n) that, given an array S, returns its balance index (any) or -1 if no balance index exists. What is the running time complexity of your function? Justify
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
