Practice mode Data Structures

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.