100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Otro

Linked Lists Class File

Puntuación
-
Vendido
-
Páginas
3
Subido en
06-11-2025
Escrito en
2025/2026

The provided code defines a simple linked list program in C++ with functionalities to insert, delete, and display items either from left to right or right to left. **Key functions:** 1. **`insertItem(LinkedLists *& head)`**: This function adds a new item to the linked list. It prompts the user for an ID and name, creates a new node, and updates the pointers accordingly. 2. **`deleteItem(LinkedLists *& head)`**: This function deletes a node from the linked list based on user-input ID. It handles various cases, including empty lists and deleting from the head or end. 3. **`displayOptions()`**: This function presents the user with options for displaying the list and returns the chosen option. 4. **`displayLtoR(LinkedLists *& head)`**: Displays the list from the head to the end, printing IDs and names of each node. 5. **`displayRtoL(LinkedLists *& head)`**: Displays the list from the end to the head, navigating back through the linked list. **Main Execution:** In the `main()` function, five items are inserted into the list, one item is deleted, and the user is prompted to choose how to display the list. The corresponding display function is called based on the user's input. Overall, the program allows for basic manipulation and viewing of a doubly linked list.

Mostrar más Leer menos
Institución
Grado








Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Grado

Información del documento

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

Temas

Vista previa del contenido

#include "LinkedLists.h"

void insertItem(LinkedLists *& head);
void deleteItem(LinkedLists *& head);
char displayOptions();
void displayLtoR(LinkedLists *& head);
void displayRtoL(LinkedLists *& head);

int main()
{
LinkedLists * head = NULL;
char answer;

// insert 5 items into the list
for (int i = 0; i < 5; i++)
{
insertItem(head);
}
// delete an item from the list
deleteItem(head);

answer = displayOptions();

if (toupper(answer) == 'A')
// display from left to right
displayLtoR(head);
else
// display from right to left
displayRtoL(head);

return 0;
}

void insertItem(LinkedLists *& head)
{
LinkedLists * temp = new LinkedLists;

cout << "ID: ";
cin >> temp->ID;
cout << "NAME: ";
cin >> temp->name;

temp->next = head;
temp->back = NULL;

if (head != NULL)
head->back = temp;

head = temp;
}

void deleteItem(LinkedLists *& head)
{
LinkedLists * lead;
LinkedLists * follow;
int IDnum;

lead = follow = head;
$15.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
tinahuynh

Conoce al vendedor

Seller avatar
tinahuynh California State University, Long Beach
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
Nuevo en Stuvia
Miembro desde
1 mes
Número de seguidores
0
Documentos
68
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

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