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.
OP's solution assumes that the binary tree is in fact an ordered binary tree (aka binary search tree): in other words a tree where each left child node is less than its parent node's value and each right child node is greater than its parent node's value.
The problem doesn't specify this constraint, though the submission tests don't seem to violate the assumption either. Either OP's assumption is incorrect and happens to work against the test cases or the challenge is not written as clearly as it could be.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Inorder Traversal
You are viewing a single comment's thread. Return to all comments →
OP's solution assumes that the binary tree is in fact an ordered binary tree (aka binary search tree): in other words a tree where each left child node is less than its parent node's value and each right child node is greater than its parent node's value.
The problem doesn't specify this constraint, though the submission tests don't seem to violate the assumption either. Either OP's assumption is incorrect and happens to work against the test cases or the challenge is not written as clearly as it could be.