Binary Tree Nodes

  • + 4 comments

    Here is Oracle solution from my HackerrankPractice repository:

    SELECT N,
        CASE
            WHEN P IS NULL THEN 'Root'
            WHEN N IN (SELECT P FROM BST) THEN 'Inner'
            ELSE 'Leaf'
        END
    FROM BST
    ORDER BY N;
    

    Feel free to ask if you have any questions :)