Tree: Preorder Traversal

  • + 2 comments

    can be done even more elegantly (less null checks)

    void Preorder(Node root) {

    if (root != null) {
        System.out.print(root.data + " ");
        Preorder(root.left);
        Preorder(root.right);
    }
    

    }