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.
- Tree: Preorder Traversal
- Discussions
Tree: Preorder Traversal
Tree: Preorder Traversal
Sort by
recency
|
12 Discussions
|
Please Login in order to post a comment
By "binary tree" they obviously mean "binary search tree"
Otherwise one can construct more than one binary tree from the provided linear input...
I wish them to get such an ambiguous problem on their interview.
PHP sol. Thanks... Node class was not provided. Bit easier in js or python.
the typescript wrapper code is incomplete and it is much easier to attempt this problem with the plain JS code (since it builds out the tree + data structures for you)
public static void preOrder(Node root) { if(root == null) { return; } System.out.print(root.data+" "); preOrder(root.left); preOrder(root.right); }