How to traverse a binary tree

Here, traverse away!

function traverseTree($rootNode) {
    if($rootNode->left != null)
    if($rootNode->right != null)
    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…

Posted Friday, October 30th, 2015 under whiteboard.

One comment so far

  1. wow, what an arrogant prick.

Leave a Reply