Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain how employee performance data is Big Data in HR.

Answered: 1 week ago