Tree Node.
EasyGiven a binary tree, identify which nodes are leaf nodes, root nodes or inner nodes.
- Leaf nodes: A node with no children
- Root nodes: A node with no parent
- Inner nodes: A node with both children and parent nodes
You are given the following table tree_node_table:
| id | p_id |
|---|---|
| integer | integer |
where p_id is the id of the parent node. Your output should contain the following columns: id, node_types (’Root’, ‘Inner’, ‘Leaf’).
Interview experiences
10 shared









Related courses

Machine Learning Engineer Interview Prep
Land your dream machine learning role at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Explore ML system design, core concepts, coding, behavioral interviews, and more.

Software Engineering Interview Prep
Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.