Binary Search Tree is a node-based binary tree data structure which has the following properties:
- The left subtree of a node contains only nodes with keys lesser than the node’s key.
- The right subtree of a node contains only nodes with keys greater than the node’s key.
- The left and right subtree each must also be a binary search tree.
although the number of permutations of numbers is but those permutations output similar trees so the number of different trees is less than and equal to:
When inserting a new node into a binary search tree, we follow these steps:
- Start at the root of the tree.
- If the tree is empty, the new node becomes the root.
- If the new node's value is less than the current node's value, move to the left child.
- If the new node's value is greater than the current node's value, move to the right child.
- Repeat steps 3 and 4 until a suitable empty position is found.
- Insert the new node in that position.