Binary Search Tree
graph TD;
A[8] --> B[3];
A --> C[10];
B --> D[1];
B --> E[6];
E --> F[4];
E --> G[7];
A binary search tree is a tree where the left child of the tree is always smaller and the right child of the subtree is always greater than the current node. This subsequently prove that on a given root, the left subtree will have children having value lesser than the current root and on the right subtree the children will have greater value than the current root node.
Inorder Traversal
Inorder traversal of a BST will result in accessing the nodes of the tree in an ascdending order of their values. This is crucial in problems where we have to access the order of the nodes in a particular fashion.
Insertion in a BST
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Deletion in a BST
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|