Your question is Binary Tree Height. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Mavericks Consulting's hierarchy analysis tool represents each organizational structure as a binary tree. Given the tree's root, return its height, measured as the number of nodes on the longest path from the root to any leaf.
Use an iterative breadth-first search. Process one complete level at a time and count how many levels the traversal contains.
The input root is either None or a nested dictionary with this structure:
value: an integer node valueleft: another node dictionary or Noneright: another node dictionary or NoneReturn an integer representing the tree height. An empty tree has height 0, and a tree containing only its root has height 1.
def tree_height(root):