You are viewing a single comment's thread. Return to all comments →
This was in C++, but I'm sure you can translate it to java. If root is NULL then return means stop the recursion
NULL
void preOrder(node *root) { if(root == NULL) return; cout << root->data << " "; preOrder(root->left); 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 →
This was in C++, but I'm sure you can translate it to java. If root is
NULL
then return means stop the recursion