It insulates against cold and heat and wards off insect enemies. Continually renewed from within, it helps keep out moisture in the rain, and prevents the tree from losing moisture when the air is dry. A: The outer bark is the tree's protection from the outside world. Your task is to complete the function isBST() which takes the root of the tree as a parameter and returns true if the given binary tree is BST, else returns false. This information is courtesy the Arbor Day Foundation. You don't need to read input or print anything. The left subtree of root node contains node The right subtree of a node contains only nodes with keys greater than the node's key.īoth the left and right subtrees must also be binary search trees. The left subtree of a node contains only nodes with keys less than the node's key.
![tree it tree it](http://diytotry.com/wp-content/uploads/2015/11/Chevron-Pallet-Ornament-Christmas-Tree.jpg)
Your task is to complete the function isBST() which takes the root of the tree as a parameter and returns true if the given binary tree is BST, else returns false.Įxpected Auxiliary Space: O(Height of the BST). Nodes with keys less than 7, this is not a BST. Since the node with value 7 has right subtree
![tree it tree it](https://www.loveyourlandscape.org/media/19887/bartlett1.jpg)
With key greater than the root node’s key. The right subtree of root node contains node With key lesser than the root node’s key and Both the left and right subtrees must also be binary search trees.Įxplanation: The left subtree of root node contains node.The right subtree of a node contains only nodes with keys greater than the node's key.
![tree it tree it](https://image.shutterstock.com/image-vector/picture-samanea-saman-tree-species-260nw-1347285263.jpg)
The left subtree of a node contains only nodes with keys less than the node's key.Note: We are considering that BSTs can not contain duplicate Nodes.