Question: Consider the following data field and method. Method maxHelper is intended to return the largest value among the first numVals values in an array; however,
Consider the following data field and method. Method maxHelper is intended to return the largest value among the first numVals values in an array; however, maxHelper does not work as intended.
private int nums;
precondition: numVals nums.length
private int maxHelperint numVals
Line : int max maxHelpernumVals ;
Line : if max numsnumVals
return max;
else
return numsnumVals ;
Which of the following best describes the conditions under which maxHelper does not work as intended?
Responses
When numVals is
When numVals is
When numVals is even
When numVals is even
When the elements of nums are in nonincreasing order
When the elements of nums are in nonincreasing order
When the elements of nums are in nondecreasing order
When the elements of nums are in nondecreasing order
Method maxHelper never works as intended.
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
