Binary Search Tree is a rooted binary tree. Its subtrees have certain properties. Each element of the binary tree is a node that has mainly 3 fields,
You might also be interested in
Binary Search Tree in Python
Height of Binary Search Tree
Insert ,Search and Display Binary Search Tree
Leaf Nodes of Binary Search Tree
Minimum & Maximum element in BST
Linked list in Python
- data or element field
- left link
- right link
For each node in a binary search tree, the data of the left node is less than the parent node and data of the right node is greater than the parent node.
It can be seen in the image above that the data in the left child node is less than the data of the parent node and data of the right child node is greater than the parent node.
There are a lot of advantages of using the binary search tree data structure, they are related to searching, sorting, using them as priority queues, etc.
To know more about binary search tree click here.
The following program has the following operations implemented
- isEmpty() : method that checks if the tree is empty.
- getRoot() : method that returns the root element of the binary search tree.
- insert() : Insertion in Binary search tree.
- search() : Method for Searching a element in BST.
- height() : Method to find the height of the binary search tree.
- displayInorder() : Method that displays Binary search tree in Inorder form.
- displayPostorder() : Method that displays Binary search tree in Postorder form.
- displayProorder() : Method that displays Binary search tree in Preorder form.
- displayLeafNodes() : Display the Leaf nodes of the Binary search tree.
- Max() : method that returns the largest element of the tree.
- Min() : method that returns the smallest element of the tree.
- commonAncestor() : method that displays that common ancestor of the two elements.
- displayNodesAtDistance() : method that displays nodes at a distance k from the root node.
- deleteElement() : method to delete a element from the binary search tree.
- deleteMax() : method to delete the largest element of the tree.
- deleteMin() : method to delete the smallest element of the tree.
C++ Program
You might also be interested in
Binary Search Tree in Python
Height of Binary Search Tree
Insert ,Search and Display Binary Search Tree
Leaf Nodes of Binary Search Tree
Minimum & Maximum element in BST
Linked list in Python
Comments
Post a Comment