You are on page 1of 9

Linked List Implementation

• Singly/Simple- forward
• Doubly- forward/backward
• Circular- can be inserted
Let's create a structure for a single node first.
Since a node consists of the data part and the
next part, here is how the structure looks:
Creating C++ Linked List

To create a linked list, you have to launch a class.


It will include the functions that control the
nodes:
Let's create three nodes in sequence. Make sure that each node
is pointing to NULL at first since the pointers will be added later
as you input the data.
Next, let's put data values and pointers into each node. Each
node, except the third one, should point to the subsequent
nodes. The third node’s tail should point to NULL.
Inserting at the Start
Inserting a new node at the start of the list means that the new
node will serve as the new head. Since it will push the former
head aside, the process uses the push() function.
Inserting at the End

If you add a new node at the end of the list, it'll become the end
of the traversal within the list. In other words, you should set the
new node to point at NULL.
Inserting at a Specific Position
The purpose of this method is to put a new node between the
head and the tail. You have to fill the data and adjust the pointer
of the new node with its previous node.

You might also like