How would you print inorder traversal of a binary tree without recursion?
Use an explicit stack to simulate the recursive call stack. The input is a nested dictionary with keys val, left, and right, where an empty child is null; return a list of values in inorder, left, root, right order.
val, left, and rightdef inorder_traversal(root):