Singly Linked List

A Singly Linked List is a linear data structure where elements (called nodes) are connected using pointers. Each node points to the next node in the sequence.


 Structure of a Singly Linked List

Each node contains:

  1. Data – the value stored

  2. Next – a reference (pointer) to the next node

Visually:

 
 
[Data | Next] → [Data | Next] → [Data | Next] → NULL
 
  • The list starts with a Head (first node).

  • The last node points to NULL (meaning the list ends).


🔹 Example

If we store: 10 → 20 → 30

It looks like:

Head

[10 | •] → [20 | •] → [30 | NULL]
 

 Key Characteristics

  • Elements are not stored in contiguous memory (unlike arrays).

  • Each node stores the address of the next node.

  • Traversal is one-directional only (forward).

  • Dynamic size (can grow or shrink at runtime).


 Basic Operations

  1. Insertion

    • At beginning

    • At end

    • At a specific position

  2. Deletion

    • From beginning

    • From end

    • By value

  3. Traversal

    • Visiting each node sequentially

  4. Search

    • Finding a value in the list


 Advantages

✔ Dynamic size
✔ Efficient insertions/deletions (especially at beginning)
✔ No memory wastage like fixed-size arrays


 Disadvantages

✘ No direct access (must traverse from head)
✘ Extra memory needed for pointers
✘ Cannot traverse backward