
401-18.1
COMP 401
Spring 2008
Assertion worksheet
What is the English equivalent for each of these assertions?
Assume that a and b are arrays [0...n] of integer and key, x, and y are integer variables.
1. {Ai: 0 <= i <= n: a[i] == 0}
2. {Ai: 0 <= i < n: a[i] <= a[i+1]}
3. {Ei: 0 <= i <= n: a[i] == 0}
4. {Ei: 0 <= i < n: a[i] > a[i+1]}
5. {Ai: 0 <= i <= n: Ej: 0 <= j <= n: |a[i]-a[j]| == 1} |x| indicates the
absolute value of x
6. {Ei: 0 <= i <= n: a[i] == key && Aj: 0 <= j < i: a[j] != key}
7. {Ai: 0 <= i <= n: a[i] == b[i]}
8. {Ai: 0 <= i <= n: a[i] == a[n-i]}
Translate each of the following into a formal assertion
9. None of the elements in a[lo...hi] is equal to zero. Assume 0 <= lo <= hi <= n.
10. All of the elements of a are even.
11. Some of the elements of a are odd.