Fair and Balanced
Let’s consider an array "balanced" if the sum of the elements on the left half of the array is equal to the sum of the elements on the right half of the array. In an array with an odd number of elements, we ignore the element in the middle when making that determination. For example,
int a[] = {17, 40, 28, 29};
is balanced, because the sum of its left half is 17 + 40 = 57, just as the sum of its right half is 28 + 29 = 57. Similarly,
int b[] = {30, 22, 11, 14, 66};
is balanced, because the sum of its left half is 30 + 22 = 52, just as the sum of its right half is 14 + 66 = 52; we ignore its middle element (11) altogether.
Answer the below in balanced.md
.
Questions

(1 point.) Is the array
{16, 26, 39, 3, 39}
balanced? 
(1 point.) Is the array
{0, 0, 0, 0, 0}
balanced? 
(4 points.) Implement a function called
balanced
that accepts two parameters: an array of integers,array
, and an integer,n
, that represents the length ofarray
. The function should returntrue
ifarray
is balanced andfalse
otherwise. Assume thatn
is positive.
Debrief

Which resources, if any, did you find helpful in answering this problem’s questions?

About how long did you spend on this problem’s questions?