• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 1 fuera de 1 páginas
Otro

UnsortedList and SortedList Class File

Document preview thumbnail
Vista previa 1 fuera de 1 páginas

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.

Vista previa del contenido

#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

Información del documento

Subido en
6 de noviembre de 2025
Número de páginas
1
Escrito en
2025/2026
Tipo
Otro
Personaje
Desconocido
$11.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
0
Artículos
68
Última venta
-



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes