Binary Tree Nodes

  • + 0 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;