You are viewing a single comment's thread. Return to all comments →
I have no idea about Java but it was fairly simple to traverse the tree without any knowledge of the language:
You always start left, then go right. Recurse deeper and print the value
void Preorder(Node root) { System.out.print(root.data + " "); if (root.left != null) { Preorder(root.left); } if (root.right != null) { Preorder(root.right); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Preorder Traversal
You are viewing a single comment's thread. Return to all comments →
I have no idea about Java but it was fairly simple to traverse the tree without any knowledge of the language:
You always start left, then go right. Recurse deeper and print the value