Here is the Python code for Binary Search Tree :- Content included:- 1.) Insertion 2.) Search Operation 3.) Deletion 4.) Minimum Node 5.) Maximum Node 6.) Preorder Traversal 7.) InOrder Traversal 8.) PostOrder Traversal class BST: def __init__(self, data): self.root = data self.left = None self.right =None def insertnode(self, data): if self.root is None: self.root = data return if self.root is data: return elif self.root > data: if self.left is not None: self.left.insertnode(data) else: self.left = BST(data) elif self.root data: if self.left is not None: self.left.searchoprn(data) else: print("Data is not present.") elif self.root self.root: if self.right: selfright = self.right.deletenode(data) ...
Here is the Python code for the Doubly Linked List :- #first of all creat a class node class Node : def __init__ ( self , data ): self . data = data self . next = None self . prev = None #now create a class of doubly linked list class DLL : def __init__ ( self ): self . head = None #function to insert the node at begining def insertatbeg ( self , data ): newnode = Node ( data ) newnode . prev = None newnode . next = self . head self . head = newnode #function to insert the node at the end def insertatend ( self , data ): newnode = Node ( data ) if self . head is None : self . head ...
It is very useful for me to learn and understand easily. Thanks for sharing your valuable information
ReplyDeletePython Online Course
Python Online Training in India
Got the most appropriate and easy to understand code.
ReplyDelete