Q. What is the result of a level-order traversal of a binary tree?
-
A.
Nodes are visited from top to bottom and left to right
-
B.
Nodes are visited from bottom to top and right to left
-
C.
Nodes are visited in sorted order
-
D.
Nodes are visited in reverse order
Solution
Level-order traversal visits nodes level by level, starting from the root and moving from left to right.
Correct Answer:
A
— Nodes are visited from top to bottom and left to right
Learn More →
Q. Which algorithm is used to find the height of a binary tree?
-
A.
Depth-first search
-
B.
Breadth-first search
-
C.
Dynamic programming
-
D.
Greedy algorithm
Solution
Depth-first search (DFS) is commonly used to calculate the height of a binary tree by recursively exploring each branch.
Correct Answer:
A
— Depth-first search
Learn More →
Showing 1 to 2 of 2 (1 Pages)