11. Python program to insert a new node at the end of the Doubly Linked List.In this program, we will create a doubly linked list and insert every new node at the end of the list. If the list is empty, then head and tail will point to the newly added node. If the list is not empty then, insert the new node at the end of the list such that tail's next will point to new node. Make new node as the new tail of the list, and its next will point to null. In the above example, node 4 was the tail of the list. Now, the new node will be inserted at the end of the list such that node 4's next will point to the new node. Make new node as the tail of the list, and its next will point to null. ALGORITHM:
a. display() will show all the nodes present in the list.
PROGRAM:Output: Adding a node to the end of the list: 1 Adding a node to the end of the list: 1 2 Adding a node to the end of the list: 1 2 3 Adding a node to the end of the list: 1 2 3 4 Adding a node to the end of the list: 1 2 3 4 5 Next TopicPython Programs |
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