A singly linked list allows only one-way traversal
A singly linked list is a list where each node stores a reference to the next node only. This makes it one-directional, allowing traversal only from head to tail.
head
--------- --------- ---------
| nodeA | --> | nodeB | --> | nodeC | --> NULL
--------- --------- ---------
Singly linked lists are useful when maintaining sequence order is important and when you can trade lookup performance for efficient insertions and deletions.
Here are some common methods used to implement a singly linked list:
insert(data)
insertAt(pos, data)
pop_back()
pop_front()
removeNode(data)
cat(listA, listB)
- catenate two listsclear
print