Singly Linked List

Most common type. F/S pointers are popular.

Definition

private class Node {
    int value;
    Node nextNode;
    public Node(int value) {
        this.value = value;
        nextNode = null;
    }
}

Basic Operations

Add

if (current.nextNode == null) {
    current.nextNode = newNode;
}

or

Delete

Reverse

Dummy Head

If we want to modify the head of a linked list, using a dummy head node will make the job easier (avoid the special case for head).

Find midpoint

Delete Node in the Middle of Singly Linked List

slow stops at the middle if the length is odd and stops at length/2 + 1 if the length is even.

Last updated