In this example, we prove that the maximum value of [2, [1, []]] is 2. We start with just the innermost element, which is 1. We know that the maximum of [1, []] is 1.
Next, we know that 2 is greater than the maximum of [1, []] since the maximum of [1, []] is 1 and 2 > 1. Then we conclude that the maximum of [2, [1, []]] is 2.
Quiz (1 point)
Prove that:
maximum value in stack [ 2, [ 1, [ ] ] ] = 2
The following properties may be helpful:
- maximum value in stack [ x, [ ] ] = x
- 2 > 1
if maximum value in stack [ 1, [ ] ] = 1, then 2 > maximum value in stack [ 1, [ ] ] = 2 > 1
if the following are true:
- a
- b = a
then b
if a > maximum value in stack xs, then maximum value in stack [ a, xs ] = a
Please write your proof in the table below. Each row should contain one claim. The last claim is the statement that you are trying to prove.