You are given the root of a binary tree, return the inorder traversal of its nodes' values.
In an inorder traversal, we recursively follow these steps:
[1, 3, 2]
Starting at the root (1), we go to its right child (2) since the left is null. From node 2, we go to its left child (3). Node 3 has no children, so we add 3 to the list. Then we go back to node 2 and add 2. Finally, we go back to the root and add 1. The result is [1, 3, 2], which is incorrect. Let's re-evaluate.
Correct Inorder Traversal:
[1].[1, 3].[1, 3, 2].[1, 3, 2].None
[]
The tree is empty, so the traversal results in an empty list.
[1, 2, 3, 4, 6, 7, 9]
Following the left-root-right pattern recursively results in the nodes being visited in their natural sorted order for a Binary Search Tree, which this example happens to be.
[1, 3, 2]