Category: Python Programs

python tutorials and learn python

Python program to create and display a doubly linked list.

Python program to create and display a doubly linked list. In this program, we will create a doubly linked list and print all the nodes present in the list. Doubly Linked List: Doubly Linked List is a variation of the linked list. The linked list is a linear data structure which can be described as…

Python program to create a doubly linked list of n nodes and display it in reverse order.

Python program to create a doubly linked list of n nodes and display it in reverse order. In this program, we create a doubly linked list and then reverse the list by reversing the direction of the list and print out the nodes. Traverse through the list by swapping the previous pointer with next pointer…

Python program to create a doubly linked list of n nodes and count the number of nodes.

Python program to create a doubly linked list of n nodes and count the number of nodes. In this program, we will create a doubly linked list and count the number of nodes present in the list. To count the node, we traverse through the list by incrementing the counter by 1. What count of…

Python program to create a doubly linked list from a ternary tree.

Python program to create a doubly linked list from a ternary tree. In this program, the given ternary tree will be converted into a corresponding doubly linked list. The ternary tree is a hierarchical data structure in which each node can have at most three children. This can be accomplished by traversing the ternary tree…

Python program to convert a given binary tree to doubly linked list.

Python program to convert a given binary tree to doubly linked list. In this program, we need to convert the given binary tree to corresponding doubly liked list. The binary tree is a tree data structure in which each node has at most two children node. This can be achieved by traversing the tree in…

Python program to sort the elements of the Circular Linked List

Python program to sort the elements of the Circular Linked List In this program, we will create a circular linked list and sort the list in ascending order. In this example, we maintain two nodes: current which will point to head and index which will point to the next node to current. The first loop,…

Python program to search an element in a Circular Linked List

Python program to search an element in a Circular Linked List In this program, we create a circular linked list and search a node in the list. 9->5->2->7->3 9->5->2->7->3<br /> Consider, above example. Suppose we need to search for node 5. To solve this problem, we will iterate through the list and compare each node…

Python program to remove duplicate elements from a Circular Linked List

Python program to remove duplicate elements from a Circular Linked List In this program, we will create a circular linked list and remove duplicate nodes from the list. We will compare a node with the rest of the list and check for the duplicate. If the duplicate is found, delete the duplicate node from the…