| | |
Summary: CMPS 282: Software Engineering, Spring 2010-11 Instructor: Paul Attie
Problem set 6 Due: Monday May 16
Department of Computer Science American University of Beirut
In all your answers, provide full annotations similar to the examples that I have presented in
class. Use the specification for IntSet that I gave in class, which is also provided on page 81
(Figure 5.2) of the textbook. Your implementation is allowed to assume only that the represen-
tation invariant holds before invocation of the method. Do not make any other assumptions.
1. (20 points) Give a specification for a union method that produces the union of two
IntSet's.
2. (20 points) This question concerns the implementation of IntSet that uses integer array
els and integer top and has representation invariant
0 top els.length
( i, j : 0 i, j < top i = j : els[i] = els[j])
Thus, we do not allow duplicates in the els array.
Give an implementation for union. Include informal annotations to justify correctness.
3. (40 points) This question concerns the implementation of IntSet that uses integer array
els and integer top and has representation invariant
0 top els.length
( i, j : 0 i, j < top i = j : els[i] = els[j])
( i : 0 i < top - 1 : els[i] els[i + 1])
|