Your question is DFS on Binary Tree. 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.
PingOne authorization policies can be represented as binary decision trees. Given the root of a binary tree, implement dfs_preorder(root) to visit every node using depth-first search and return the node values in preorder: visit the current node, then its left subtree, then its right subtree.
Represent each node as a dictionary with keys value, left, and right. A missing child is represented by None.
root, either None or a nested binary-tree dictionary. Each value is an integer.def dfs_preorder(root):