Doubly Linked List | Set 1 ( Introduction and Insertion ) | Adding a node at the front of the list ; 1. allocate node * 2. 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
public void push ( int new_data ) { Node new_Node = new Node ( new_data ) ; new_Node . next = head ; new_Node . prev = null ; if ( head != null ) head . prev = new_Node ; head = new_Node ; }