Insert a Node at Front/Beginning of Doubly Linked List
Last Updated : 12 Dec, 2025
Given a Doubly Linked List, insert a new node at the beginning/start/front of the linked list.
Examples:
Input: Linked List = 2 <-> 3 <-> 4 , New Node = 1 Output: 1 <-> 2 <-> 3 <-> 4 Explanation: Node 1 is inserted at the beginning and is the new head of the doubly linked list.
Input: Linked List = NULL, New Node = 10 Output: 10 Explanation: Node 1 is the only node in the doubly linked list.
Approach:
To insert a new node at the beginning/front of doubly linked list, we create a new node with its previous pointer as NULL and next pointer to the current head of the doubly linked list.
Then, we check if the linked list is not empty then we update the previous pointer of the current head to the new node.
Finally, we return the new node as the head of the linked list.