This C++ code provides a basic implementation of a linked list. The code is created by Ganeshaanand (Rishi) Balasubramanian, a Master of Applied Science in Electrical and Computer Engineering from Dalhousie University, Halifax, Canada (2022).
The linked list implementation consists of a LinkNode
class representing a node in the linked list. Each node has two fields: key
, which stores the data for the node, and next
, which points to the next node in the list.
The code includes the following functions:
RootIns
: Inserts a new node at the root of the linked list.SpecificIns
: Inserts a new node at a specific point in the linked list.EndIns
: Inserts a new node at the end of the linked list.display
: Prints the contents of the linked list.Remove
: Removes a node from the linked list.RemoveSpecific
: Removes a specific node from the linked list.ListLength
: Returns the number of nodes in the linked list.
- Clone the repository or download the project files.
- Compile the code using a C++ compiler (supporting C++11 or later) with the necessary header files included.
- Run the compiled executable.
The code creates a linked list with 10 nodes and performs various operations such as inserting nodes at the root, specific positions, and the end. It also removes nodes from the list and calculates the size of the linked list.
Please note that this implementation is for educational purposes and may not cover all scenarios or optimizations.
Feel free to explore and modify the code to suit your specific needs. Happy coding!