Tree Node Type (Root, Inner, Leaf)
Medium
Hierarchical Data
Each row of Tree is a node with its parent. Label every node 'Root' if it has no parent, 'Leaf' if it has a parent but no children and 'Inner' otherwise. Order by id.
Table schema
Tree(id INT PRIMARY KEY, p_id INT NULL)Sample data
id | p_id
1 | NULL
2 | 1
3 | 1
4 | 2
5 | 2
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.