This project implements a singly linked list in C++ as part of the CENG 218 Data Structures laboratory assignment (2025–2026 Spring).
The implementation provides common linked list operations such as insertion, deletion, element access, copying, comparison, and traversal. Additionally, extra functions were implemented to analyze and manipulate nodes within the list.
A menu-driven console interface is included to allow interactive testing of all linked list operations.
push_front()– Insert element at the beginningpush_back()– Insert element at the endinsert_at()– Insert element at a specific indexinsert_after()– Insert element after a given index
pop_front()– Remove the first elementpop_back()– Remove the last elementerase_at()– Remove element at a given indexerase()– Remove the first occurrence of a valueclear()– Delete all nodes
front()– Access the first elementback()– Access the last elementat()– Access element at a specific index
size()– Returns number of nodesempty()– Checks whether the list is empty
operator=– Assignment operator (deep copy)operator==– List comparisonoperator<<– Stream output for printing list contents
findMiddleNode()
Returns the middle node of the linked list.
- If the list has an odd number of nodes, the exact middle node is returned.
- If the list has an even number of nodes, the second middle node is returned.
- Returns
nullptrif the list is empty.
getSmallestNode()
Returns the node containing the lexicographically smallest string in the list.
- Returns
nullptrif the list is empty.
moveSmallestToFront()
Finds the smallest node and moves it to the front of the linked list.
Edge cases handled:
- Empty list
- Single-node list
.
├── Node.h
├── LinkedList.h
├── LinkedList.cpp
├── main.cpp
└── README.md
Node.h
- Defines the
Nodeclass used in the linked list.
LinkedList.h
- Declares the
LinkedListclass and all its methods.
LinkedList.cpp
- Contains the implementation of linked list operations.
main.cpp
- Menu-driven program to test linked list functionality.
1. Push Back
2. Push Front
3. Insert At
4. Pop Back
5. Pop Front
6. Erase At
7. Print List
8. Find Middle Node
9. Get Smallest Node
10. Move Smallest To Front
0. Exit
- Singly Linked List
- Dynamic Memory Management
- Deep Copy
- Operator Overloading
- Pointer Manipulation
- Menu-driven CLI program
CENG 218 – Data Structures Computer Engineering Lab Assignment 2025–2026 Spring