We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This can also be accomplished without using a subquery:
SELECT N, CASE WHEN P IS NULL THEN 'Root' ELSE DECODE(CONNECT_BY_ISLEAF, 1, 'Leaf', 'Inner') END TP
FROM BST
START WITH P IS NULL
CONNECT BY PRIOR N = P
ORDER BY 1;
Cookie support is required to access HackerRank
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 →
This can also be accomplished without using a subquery:
SELECT N, CASE WHEN P IS NULL THEN 'Root' ELSE DECODE(CONNECT_BY_ISLEAF, 1, 'Leaf', 'Inner') END TP FROM BST START WITH P IS NULL CONNECT BY PRIOR N = P ORDER BY 1;