Binary Tree Nodes

  • + 1 comment

    I used Oracle connect by to solve this problem:

    select n, decode("leaf", 0, decode("level", 1, 'Root', 'Inner'), 'Leaf') node_type from (select n, connect_by_isleaf "leaf", level "level" from bst start with p is null connect by prior n = p) order by n;