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 distinct cld.N
, case when pr.N is null then 'Leaf'
when cld.P is null then 'Root'
when pr.N is not null then 'Inner' end as node_type
from BST cld
left join BST pr
on cld.N = pr.P
order by cld.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 →
select distinct cld.N , case when pr.N is null then 'Leaf' when cld.P is null then 'Root' when pr.N is not null then 'Inner' end as node_type from BST cld left join BST pr on cld.N = pr.P order by cld.N