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.
select n, decode("leaf", 0, decode("level", 1, 'Root', 'Inner'), 'Leaf') node_type from (select n, connect_by_isleaf "leaf", level "level" from bst start with p is null connect by prior n = p) order by n;
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 →
I used Oracle connect by to solve this problem:
select n, decode("leaf", 0, decode("level", 1, 'Root', 'Inner'), 'Leaf') node_type from (select n, connect_by_isleaf "leaf", level "level" from bst start with p is null connect by prior n = p) order by n;