You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue details:
Given the root node of a binary tree, can you determine if it's also a binary search tree?
Complete the function which has parameter: a pointer to the root of a binary tree. It must return a boolean denoting whether or not the binary tree is a binary search tree. You may have to write one or more helper functions to complete this challenge.
Your device hardware:
Issue details:
Given the root node of a binary tree, can you determine if it's also a binary search tree?
Complete the function which has parameter: a pointer to the root of a binary tree. It must return a boolean denoting whether or not the binary tree is a binary search tree. You may have to write one or more helper functions to complete this challenge.
boolean checkBST(Node root) {
return checkBSTUtil(root, null, null);
}
private boolean checkBSTUtil(Node root, Node min, Node max){
if(root == null){
return true;
}
if(min != null && min.data >= root.data){
return false;
}
if(max != null && root.data >= max.data){
return false;
}
return checkBSTUtil(root.left, min, root) && checkBSTUtil(root.right, root, max);
}
Log (optional):
The text was updated successfully, but these errors were encountered: