A singly linked list is a fundamental data structure in computer science, consisting of a sequence of elements where each element points to the next one in the sequence.
- Dynamic size
- Efficient insertion and deletion at the beginning
- Sequential access to elements
-
Insertion
- At the beginning
- At the end
- At a specific position
-
Deletion
- From the beginning
- From the end
- From a specific position
-
Traversal
- Print all elements
-
Search
- Find an element by value
Each node in a singly linked list consists of:
- Data: The value stored in the node.
- Next Pointer: A reference to the next node in the list.
struct Node {
int data;
struct Node* next;
};