A binary search tree is built by inserting 30, 50, 10, 40, 20, 60 in that order. What is its level-order traversal?
Correct answer A. 30, 10, 50, 20, 40, 60
Explanation
The tree has root 30, left child 10 with right child 20, and right child 50 with children 40 and 60. Level order visits depth 0 (30), then depth 1 left to right (10, 50), then depth 2 left to right (20, 40, 60). It is implemented with a queue. The insertion order is not the level order, and 30, 10, 20, 50, 40, 60 is preorder.
Answer checked How we write and check questions
Discussion