We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I am confused. I know what the order of insertion in a Binary Search Tree is but the problem said "given the root node of a binary tree", not "given a root node of a binary search tree", so we can't assume the input will be inserted by the order of insertion in a BST. Besides, the objective of the problem is to verify if the Binary Tree given is a BST or not. If the binary tree is constructed with a BST's order of insertion, then the output will always be 'Yes'
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Trees: Is This a Binary Search Tree?
You are viewing a single comment's thread. Return to all comments →
I am confused. I know what the order of insertion in a Binary Search Tree is but the problem said "given the root node of a binary tree", not "given a root node of a binary search tree", so we can't assume the input will be inserted by the order of insertion in a BST. Besides, the objective of the problem is to verify if the Binary Tree given is a BST or not. If the binary tree is constructed with a BST's order of insertion, then the output will always be 'Yes'