Question 11
EasyWhat is a subtree?
- A.
A node together with all of its descendants
- B.
Any two nodes
- C.
A tree with no nodes
- D.
The path from the root to a leaf
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
What is a subtree?
A node together with all of its descendants
Any two nodes
A tree with no nodes
The path from the root to a leaf
Sign up free to see the answer and a step-by-step explanation.
A binary tree has root 1, left child 2 and right child 3. What is its inorder traversal?
3 1 2
2 1 3
2 3 1
1 2 3
Sign up free to see the answer and a step-by-step explanation.
A binary tree has root 1. Node 1's children are 2 (left) and 3 (right), and node 2's children are 4 (left) and 5 (right). What is its preorder traversal?
4 5 2 3 1
1 2 3 4 5
4 2 5 1 3
1 2 4 5 3
Sign up free to see the answer and a step-by-step explanation.
A binary tree has root 1. Node 1's children are 2 (left) and 3 (right), and node 2's children are 4 (left) and 5 (right). What is its postorder traversal?
4 5 2 3 1
1 2 4 5 3
4 2 5 1 3
5 4 3 2 1
Sign up free to see the answer and a step-by-step explanation.
A binary tree has root 1. Node 1's children are 2 (left) and 3 (right), and node 2's children are 4 (left) and 5 (right). What is its level-order traversal?
1 2 3 4 5
1 3 2 5 4
4 5 2 3 1
1 2 4 5 3
Sign up free to see the answer and a step-by-step explanation.
A binary tree has root 1. Node 1's children are 2 (left) and 3 (right), and node 2's children are 4 (left) and 5 (right). How many leaf nodes does it have?
5
2
1
3
Sign up free to see the answer and a step-by-step explanation.
What is a perfect binary tree?
A tree in which every internal node has two children and all leaves are at the same level
Any tree with an even number of nodes
A tree with only one leaf
A tree whose values are sorted
Sign up free to see the answer and a step-by-step explanation.
In a binary tree, what is the largest possible number of nodes at level k (the root is level 0)?
k
2k
k²
2^k
Sign up free to see the answer and a step-by-step explanation.
What is a skewed binary tree?
A tree with all leaves at one level
An empty tree
A tree in which every node has only one child, so it looks like a list
A tree with three children per node
Sign up free to see the answer and a step-by-step explanation.
In a general tree, what is the degree of a node?
The number of its ancestors
The number of children it has
Its value
Its depth
Sign up free to see the answer and a step-by-step explanation.