Here, traverse away!
function traverseTree($rootNode) {
if($rootNode->left != null)
traverseTree($rootNode->left);
if($rootNode->right != null)
traverseTree($rootNode->right);
echo $rootNode->value;
}
Now and only now your interviewers will be impressed with your ability to code! YAY!. Never mind the decade of hard work that you’ve obviously put into learning how to code or the fact that every employer you’ve ever left offered a handsome counter-offer to keep you working there, no. Now it’s clear that you can code because you can traverse any binary tree that you come across. Your career at Binary Tree Traversal Experts LLC can finally commence…
wow, what an arrogant prick.