| Start |
|---|
| Binary Search Tree - Insertion (Python) This is a simple implementation of Binary Search Tree Insertion using Python. An example is shown below: Following the code snippet each image shows the execution visualization which makes it easier to visualize how this code works. |
| Binary Search Tree - Deletion(C++) Before starting with deletion I just want to put some lights on what is a Binary search tree(BST), Each node in a BST can have maximum of two nodes(left and right child).The left sub-tree of a node has a key less than or equal to its parent node's key. The right sub-tree of a node has a key greater than to its parent node's key. Deleting a node in a tree while maintaining its Binary search tree property. There are three cases to be considered while deleting a node.
Explanation of cases:
Note: The minimum in the right sub tree can have a maximum of one child and that too right child if it's having the left child that means it's not the minimum value or it's not following BST property. The structure of a node in a tree and the code for Deletion: Time complexity of above code is O(h), where h is the height of the tree. |
| Lowest common ancestor in a BST Consider the BST: Lowest common ancestor of 22 and 26 is 24 Lowest common ancestor of 26 and 49 is 46 Lowest common ancestor of 22 and 24 is 24 Binary search tree property can be used for finding nodes lowest ancestor Psuedo code: |
Binary Search Tree - Python """ Create different node and insert data into it""" |
Read Article
https://develop.horje.com/learn/1434/reference