Insertion in doubly linked list at beginningAs in doubly linked list, each node of the list contain double pointers therefore we have to maintain more number of pointers in doubly linked list as compare to singly linked list. There are two scenarios of inserting any element into doubly linked list. Either the list is empty or it contains at least one element. Perform the following steps to insert a node in doubly linked list at beginning.
Since, the node being inserted is the first node of the list and therefore it must contain NULL in its prev pointer. Hence assign null to its previous part and make the head point to this node. Algorithm :
Write OVERFLOW C FunctionOutput Enter the item which you want to insert? 12 Press 0 to insert more ? 0 Enter the item which you want to insert? 23 Press 0 to insert more ? 2 Output Enter the item which you want to insert? 12 Press 0 to insert more ? 2 Next TopicDoubly Linked List |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India