```
set::set()
{
cardinality = 0;
setlist.resize(DEFAULTSIZE, false);
}
set::set(int n)
{
cardinality = 0;
setlist.resize(50000, false);
}
bool set::empty() const
{
if ( setlist.empty() )
{
return true;
}
return false;
}
void set::insert(int x)
{
if (x >= 0 && x <= DEFAULTSIZE)
{
setlist.insert(setlist.end(), 1, x);
cardinality++;
}
}
int set::getLargest() const
{
if ( !setlist.empty() )
{
*( max_element( setlist.begin(), setlist.end() ) );
}
}
int set::getSmallest() const
{
if ( !setlist.empty() )
{
*( min_element( setlist.begin(), setlist.end() ) );
}
}
void set::dump() const
{
copy (setlist.begin(), setlist.end(), ostream_iterator<int>(cout," "));
cout << endl;
}
bool set::isIn(int x) const
{
*( find( setlist.begin(), setlist.end(), x) );
}
```

**THIS IS THE CLASS FILE:**

```
public :
set(); // default constructor - constructs an empty set of integers in range 0 to DEFAULTSIZE -1
set(int n);
// pre : n >= 0 and n <= 500000
// post : constructs an empty set of integers in range 0 to n-1
bool empty() const;
// pre : none
// post : returns true if set empty and otherwise false
bool isIn(int x) const;
// pre : none
// post : returns true if x is in set and otherwise false
void dump() const;
// pre : none
// post : dumps out the valus in set (separated by white space)
int getCardinality() const;
// pre : none
// post : returns the number of elements in the set
void insert(int x);
// pre : none
// post : inserts x into this set (if in range)
int getSmallest() const;
// pre : set is not empty
// post : returns smallest element in the set
int getLargest() const;
// pre : set is not empty
// post : returns largest element in the set
```

There are a few problems with the way these functions work:

1. When I insert elements into the vector, I cannot insert an element higher than 1.. only 0's and 1's.

2. When I dump the elements all I see are 0's and 1's

3. I don't understand if set(int n) is correct or not? Can anyone clarify?

4. Do all the other functions look right?

Help would be appreciated.

Thanks :)