Binary Tree Nodes

  • + 1 comment

    Great stuff. It didn't work in MS SQL directly so here is my translation of your solution into MS SQL:

    select N, case when P is null then 'Root' when(SELECT COUNT(*) FROM BST WHERE P=B.N)>0 then 'Inner' else 'Leaf' end FROM BST B ORDER BY N;