Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Tree Node Type (Root, Inner, Leaf)

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.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.