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.

Text in a problem description: "A binary tree is not a binary search if there are duplicate values"
Text in 'Binary Trees and Binary Search Trees' link: "Each element in the left subtree of t is less than or equal to the root element".
Which one is correct?

My question was not about < or <=. This is about duplicates allowed or not.
I didn't finish task yet. However for this part, I have couple lines:
if (n->data*<=*n->left->data) {isnotBST=true; return false;}
"<=" means no duplicates, as in problem description.
I submitted both, "<=" gives 16 points, "<" gives 11 points. So, they are not consistent.
Also: there is comment of moderator "Sorry! Java and C++ will be fixed in the next few hours". I see comment Java is working. What about C++?

There is no discrepency here. Both statements hold. In the tree there can be equivalent values. If during your search you encounter equivalent values, it IS a binary tree; however, it IS NOT a BST. That would be the difference. In the case of the equivalent values you would return 0.

## Trees: Is This a Binary Search Tree?

You are viewing a single comment's thread. Return to all comments →

Text in a problem description: "A binary tree is not a binary search if there are duplicate values" Text in 'Binary Trees and Binary Search Trees' link: "Each element in the left subtree of t is

less than or equalto the root element". Which one is correct?Either is valid as long as the problem creator is consistent and the test cases match the chosen definition.

My question was not about < or <=. This is about duplicates allowed or not. I didn't finish task yet. However for this part, I have couple lines: if (n->data*

<=*n->left->data) {isnotBST=true; return false;} "<=" means no duplicates, as in problem description. I submitted both, "<=" gives 16 points, "<" gives 11 points. So, they are not consistent. Also: there is comment of moderator "Sorry! Java and C++ will be fixed in the next few hours". I see comment Java is working. What about C++?With death comes honor, with honor, redemption.

There is no discrepency here. Both statements hold. In the tree there can be equivalent values. If during your search you encounter equivalent values, it IS a binary tree; however, it IS NOT a BST. That would be the difference. In the case of the equivalent values you would return 0.