Binary Tree Nodes

  • + 0 comments

    select b1.n, case when n = (select n from bst where p is NULL) then 'Root' when b1.n in (select b2.n from bst b2 left join bst b3 ON b2.n=b3.p where b3.p IS NULL) then 'Leaf' else 'Inner' end from bst b1 order by n asc