You are viewing a single comment's thread. Return to all comments →
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;
Seems like cookies are disabled on this browser, please enable them to open this website
Binary Tree Nodes
You are viewing a single comment's thread. Return to all comments →
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;