Binary Tree Nodes

  • [deleted]
    + 3 comments

    My submission in Oracle. Using the exists clause would prove to be more efficient SELECT N ,(CASE WHEN P IS NULL THEN 'Root' WHEN EXISTS (SELECT P FROM BST B WHERE A.N=B.P) THEN 'Inner' ELSE 'Leaf' END) FROM BST A ORDER BY N;