Question: Write a method named isMasonA() in java please explain each step. I would rate positively. Thanks. public static boolean isMasonA(int array[]) that returns true if
- Write a method named isMasonA() in java please explain each step. I would rate positively. Thanks.
- public static boolean isMasonA(int array[])
- that returns true if the array is MasonA false otherwise.
- An array is called MasonA if it has the following properties: * - The value of the first element equals the sum of the next two elements, which is equals to the next three elements, equals to the sum of the next four elements, etc. * - It has a size of x*(x+1)/2 for some positive integer x . * * For example {6, 2, 4, 2, 2, 2, 1, 5, 0, 0} is MasonA, whereas {2, 1, 2, 3, 5, 6} is not */
- The value of the first element equals the sum of the next two elements, which equals to the next three elements, which equals to the sum of the next four elements, etc.
- for example:
- input array
{6, 2, 4, 2, 2, 2, 1, 5, 0, 0}
output
| true (6=2+4=2+2+2=1+5+0+0) |
input ={2, 1, 2, 3, 5, 6}
output = false (2 !=1+2 != 3+5+6)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
