Question: suppose IntSets are implemented using vectors and its els component was kept sorted in increasing size. give the rep invariant and abstraction function for implementation.

suppose IntSets are implemented using vectors and its els component was kept sorted in increasing size. give the rep invariant and abstraction function for implementation. Also implement repOk and toString method
public class IntSet { // OVERVIEW: IntSets are unbounded, mutable sets of integers. private Vector els; // the rep // constructors public IntSet () { // EFFECTS: Initializes this to be empty. els = new Vector(); } // methods public void insert (int x) { // MODIFIES: this // EFFECTS: Adds x to the elements of this. Integer y - new Integer (x); if (getIndex(y) = 0; } private int getIndex (Integer x) { // EFFECTS: If x is in this returns index where x appears else returns - 1. for (int i = 0; i = 0; } private int getIndex (Integer x) { // EFFECTS: If x is in this returns index where x appears else returns - 1. for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
