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.
- Prepare
- SQL
- Advanced Select
- Binary Tree Nodes
- Discussions
Binary Tree Nodes
Binary Tree Nodes
Sort by
recency
|
2461 Discussions
|
Please Login in order to post a comment
SELECT N, CASE WHEN P IS NULL THEN 'Root' WHEN N IN (SELECT P FROM BST) THEN 'Inner' ELSE 'Leaf' END AS Type FROM BST ORDER BY N;
select n, case when p is null then 'Root' when n = any (select n where n in (select p from BST ) )then 'Inner' else 'Leaf' end as abc from BST order by n