Category: Python Programs

python tutorials and learn python

Created with Sketch.

Python program to search an element in a doubly linked list.

Python program to search an element in a doubly linked list. In this program, we need to search a given node in a doubly linked list. To solve this problem, we will traverse through the list using a node current. Current points to head and start comparing searched node data with current node data. If…
Read more

Python program to rotate doubly linked list by N nodes.

Python program to rotate doubly linked list by N nodes. In this program, we need to create a doubly linked list and rotate it by n node. This can be achieved by maintaining a pointer that starts from the head node and traverses the list until current points to the nth node. Move the list…
Read more

Python program to remove duplicate elements from a Doubly Linked List.

Python program to remove duplicate elements from a Doubly Linked List. In this program, we will create a doubly linked list and remove the duplicate, if present, by traversing through the list. List after removing duplicates: In the above list, node2 is repeated thrice, and node 3 is repeated twice. Current will point to head,…
Read more

Python program to insert a new node at the middle of the Doubly Linked List.

Python program to insert a new node at the middle of the Doubly Linked List. In this program, we create a doubly linked list and insert a new node in the middle of the list. If the list is empty, both head and tail will point to the new node. If the list is not…
Read more

Python program to insert a new node at the end of the Doubly Linked List.

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…
Read more

Python program to insert a new node at the beginning of the Doubly Linked list.

Python program to insert a new node at the beginning of the Doubly Linked list. In this program, we will create a doubly linked list and insert every new node at the beginning of the list. If the list is empty, then head and tail will point to the newly added node. If the list…
Read more

Python program to find the maximum and minimum value node from a doubly linked list.

Python program to find the maximum and minimum value node from a doubly linked list. In this program, we will create a doubly linked list then, iterate through the list to find out the minimum and maximum node. We will maintain two variables min and max. Min will hold the minimum value node, and max…
Read more

Python program to delete a new node from the middle of the doubly linked list.

Python program to delete a new node from the middle of the doubly linked list. In this program, we will create a doubly linked list and delete a node from the middle of the list. If the list is empty, display the message “List is empty”. If the list is not empty, we will calculate…
Read more

Python program to delete a new node from the end of the doubly linked list.

Python program to delete a new node from the end of the doubly linked list. In this program, we will create a doubly linked list and delete a node from the end of the list. If the list is empty, print the message “List is empty”. If the list is not empty, the tail’s previous…
Read more

Python program to delete a new node from the beginning of the doubly linked list.

Python program to delete a new node from the beginning of the doubly linked list. In this program, we will create a doubly linked list and delete a node from the beginning of the list. If the list is empty, print the message “List is empty”. If the list is not empty, we will make…
Read more