https://github.com/wwi2196/linked-list
This project features a simple singly linked list implementation. The `LinkedList` class provides essential operations including adding nodes to the start or end, inserting nodes before or after specific values, deleting nodes, and searching for values. The list can be displayed to show all its elements.
https://github.com/wwi2196/linked-list
Last synced: 3 months ago
JSON representation
This project features a simple singly linked list implementation. The `LinkedList` class provides essential operations including adding nodes to the start or end, inserting nodes before or after specific values, deleting nodes, and searching for values. The list can be displayed to show all its elements.
- Host: GitHub
- URL: https://github.com/wwi2196/linked-list
- Owner: WWI2196
- License: apache-2.0
- Created: 2024-07-11T11:50:08.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-07-22T18:25:37.000Z (11 months ago)
- Last Synced: 2025-01-29T22:45:02.819Z (5 months ago)
- Language: C++
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Linked List
This project provides a simple implementation of a singly linked list in C++. The `LinkedList` class supports basic operations such as adding, deleting, and searching for elements.## Overview
The `LinkedList` class includes methods to:
- Add elements to the end of the list.
- Add elements to the start of the list.
- Add elements before or after a specified value.
- Display the list.
- Search for an element.
- Delete a specific value from the list.### Class Definition
#### `Node` Class
The `Node` class represents a node in the linked list, containing:
- `data`: The value stored in the node.
- `next`: A pointer to the next node in the list.#### `LinkedList` Class
The `LinkedList` class provides the following methods:
- **Constructor**: Initializes an empty list.
- **Destructor** (commented out): Intended to free memory allocated for nodes.
- **`addData_toEnd(int data)`**: Adds a new node with the specified value to the end of the list.
- **`addData_toStart(int data)`**: Adds a new node with the specified value to the start of the list.
- **`addData_afterValue(int afterData, int data)`**: Adds a new node with the specified value after a node with a given value.
- **`addData_beforeValue(int afterData, int data)`**: Adds a new node with the specified value before a node with a given value.
- **`display()`**: Prints the values of all nodes in the list.
- **`search(int data)`**: Searches for a node with the specified value.
- **`deleteValue(int data)`**: Deletes the first node with the specified value.