Tree: Inorder Traversal

  • + 0 comments

    JavaScript:

    function inOrder(root) {
      let answer = '';
      
      function process(node) {
        if(node!=null) {
          process(node.left);
          answer += `${node.data} `;
          process(node.right);
        }
      }
      process(root);
      
      console.log(answer);
      
    }