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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!