Question: Suppose that we are given an array A with n > 2 elements, AO),..., A[n - 1), each of which is an integer. Write an
Suppose that we are given an array A with n > 2 elements, AO),..., A[n - 1), each of which is an integer. Write an assertion that the numbers in A are in a jagged order, that is, each subsequent number in the array must be alternatingly larger or smaller than the previous. For example the arrays (0,1,0, 2, 1, 4, 3) and (5,2, 3, 2, 6) are both jagged, while (0,1,2, 1, 0) and [0,1,0,1,1,1,0) are not jagged. Reminder an assertion is not the same thing as a definition Hint: in a jagged array, the value at each index of the array must be either strictly greater than all of its neighbors, or strictly less than all of its neighbors
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
