Print a binary tree level by level, replacing missing nodes with "*"; leaf nodes are separated by one space and each parent node is positioned relative to its child nodes going upward (rest of the prompt is points-walled).
Asked in the phone screen (coding) stage. Visible part of 1p3a post; remainder hidden behind points wall.
Implement print_tree(root). root is a nested dictionary with value, left, and right keys, or None; values are single non-whitespace characters. Return a list of strings, one per level. Include "*" for every missing position through the deepest real node, and preserve leading spaces needed for alignment.
value, left, and right keys.None.def print_tree(root):