In the sample input given in question,
The tree is given as 1.left = 2, 1.right = 3, 2.left = 4.
Preorder traversal is recursive, correct? I believe the traversal would be 1, 2, 4, 3.
or 1, 2, 4, null, 3 to account for non-existing right child of 2.
Can someone please explain if my thinking is correct or wrong, and if wrong, where am I going wrong?