• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 1 pages
Other

UnsortedList and SortedList Class File

Document preview thumbnail
Preview 1 out of 1 pages

The provided code defines two classes for managing lists of integers: `UnsortedList` and `SortedList`. Both classes include the following features: 1. **UnsortedList**: - Stores a fixed number of items (defined by `SIZE` which is set to 10). - Contains private members for storing IDs and the current length of the list. - Public methods include: - Constructor and destructor. - `isFull()` and `isEmpty()` to check the list's status. - `insertItem(int id)` to add an ID. - `deleteItem(int id)` to remove an ID. - `displayList()` to show the contents of the list. 2. **SortedList**: - Similar to `UnsortedList`, it also handles a fixed number of items. - Contains private members for storing numbers and the current length of the list. - Public methods include: - Constructor and destructor. - `isFull()` and `isEmpty()` functions. - `insertItem(int item)` to add a number while maintaining sorted order. - `deleteItem(int item)` to remove a number. - Search methods: `binarySearch(int item)` for efficient lookup in a sorted list and `linearSearch(int item)` for checking each element. - `displayList()` to present the contents. Both classes support basic operations on the lists while providing functionalities specific to their unsorted or sorted nature.

Content preview

#include <iostream>
#include <string>
#include <cctype>
using namespace std;

#ifndef UNSORTEDLIST_H
#define UNSORTEDLIST_H

const int SIZE = 10;

class UnsortedList
{
private:
int idNumbers[SIZE];
int length;
public:
UnsortedList();
~UnsortedList();
bool isFull() const;
bool isEmpty() const;
void insertItem(int id);
void deleteItem(int id);
void displayList() const;
};

#endif


#ifndef SORTEDLIST_H
#define SORTEDLIST_H

#include <iostream>
#include <string>
using namespace std;

class SortedList
{
private:
int length;
int numbers[SIZE];
public:
SortedList();
~SortedList();
bool isFull() const;
bool isEmpty() const;
void insertItem(int item);
void deleteItem(int item);
int binarySearch(int item);
int linearSearch(int item);
void displayList() const;
};

#endif

Document information

Uploaded on
November 6, 2025
Number of pages
1
Written in
2025/2026
Type
Other
Person
Unknown
$11.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
68
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions