/* Ajith - Syntax Higlighter - End ----------------------------------------------- */

12.25.2012

Deleting a Node from a Singly Linked List

This article is part of article series - "Datastructures"

Previous Article: Implementation of Singly Linked List.
Next Article: Reversing a Singly Linked List

Deletion of a Node from a Singly Linked List
Similar to insertion we have three cases for deleting a Node from a Singly Linked List.

  • Deleting First Node in Singly Linked List

    To complete deletion of firstNode in the list we have to change Head pointing to Next of firstNode.

    Pseudocode:
    firstNode = Head
    
    Head = firstNode->Next
    
    free firstNode
    Complexity:
    Time Complexity: O(1)
    Space Complexity: O(1)

Detecting First Node in a Loop in the List

This article is part of article series - "Datastructures"

Previous Article: Detecting a Loop in Singly Linked List - Tortoise and Hare.
Next Article: Finding Nth node from end of a Singly Linked List.

Once we confirm that there is a Loop in a Singly Linked List we will see how to determine first node of the loop.