Binary Tree Nodes

  • + 0 comments

    MySQL / PostgreSQL

    select N, case when P is null then 'Root' when N not in (select P from BST where P is not null) then 'Leaf' else 'Inner' end as Type from BST order by N;