Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started