A programmer develops the procedure maxPairSum () to compute the
sum of subsequent pairs in a list of numbers and return the maximum sum.
For example, for a list of [2, 3, 4, 1], the sums of subsequent pairs are
5 (from 2 + 3), 7 (from 3 + 4), and 5 (from 4 + 1). The procedure should
return the maximum sum of 7.
PROCEDURE maxPairSum (nums) {
i - 1
maxSum - 0
REPEAT UNTIL (i = LENGTH (nums) )
{
sum - nums [i] + nums [i + 1]
{
IF (sum > maxSum)
maxSum - sum
}
i+1
}
RETURN maxSum
}
The programmer tests it with maxPairSum [5, 4, -4, 3, 2]) and
sees a return value of 9.
Can the programmer conclude that the procedure works correctly for all
inputs?
Choose 1 answer:
Yes, that test case is sufficient proof that the procedure works as
A
intended for all possible lists of numbers.
No, since the expected return value is not 9 for that test case.
B
No, but the programmer can conclude that it works for all lists of
C
integers.
D
No, they've only verified that it works for that test case. Additional
analysis and reasoning is necessary.
Not the question you are looking for? Ask here!
Enter question by text
Enter question by image
Unlock Smarter Learning with AskSia Super!
Join Super, our all-in-one AI solution that can greatly improve your learning efficiency.