Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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; iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started