본문 바로가기
데이터 분석/SQL 연습문제

Binary Tree Nodes (HackerRank)

2022. 11. 3.
 

Binary Tree Nodes | HackerRank

Write a query to find the node type of BST ordered by the value of the node.

www.hackerrank.com

Write a query to find the node type of Binary Tree ordered by the value of the node. Output one of the following for each node:

풀이

제출한 답

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

-> P에 있는 값이 N에도 있으면 Inner

2022.11.03

'데이터 분석 > SQL 연습문제' 카테고리의 다른 글

Ollivander's Inventory (HackerRank)  (0) 2022.11.05
SQL Project Planning (HackerRank)  (0) 2022.11.04
Weather Observation Station 5 (HackerRank)  (0) 2022.10.12
Occupations (HackerRank)  (0) 2022.10.11
New Companies (HackerRank)  (0) 2022.10.05

댓글