Doubly Linked List | Set 1 ( Introduction and Insertion ) | Adding a node at the front of the list ; 1 & 2 : Allocate the Node & Put in the data ; 3. Make next of new node as head and previous as NULL ; 4. change prev of head node to new node ; 5. move the head to point to the new node
def push ( self , new_data ) : NEW_LINE INDENT new_node = Node ( data = new_data ) NEW_LINE new_node . next = self . head NEW_LINE new_node . prev = None NEW_LINE if self . head is not None : NEW_LINE INDENT self . head . prev = new_node NEW_LINE DEDENT self . head = new_node NEW_LINE DEDENT