You are viewing a single comment's thread. Return to all comments →
SELECT n, CASE WHEN p IS NULL THEN 'Root' WHEN n IN (SELECT p FROM BST where p is not null) THEN 'Inner' ELSE 'Leaf' END AS type FROM BST 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 →
MS SQL
SELECT n, CASE WHEN p IS NULL THEN 'Root' WHEN n IN (SELECT p FROM BST where p is not null) THEN 'Inner' ELSE 'Leaf' END AS type FROM BST ORDER BY n;