A binary search tree is built by inserting 50, 30, 70, 20, 40, 60, 80 in that order. What is its preorder traversal?
Correct answer A. 50, 30, 20, 40, 70, 60, 80
Explanation
The tree has root 50, left child 30 (with children 20 and 40) and right child 70 (with children 60 and 80). Preorder visits the node, then its left subtree, then its right subtree: 50, then 30, 20, 40, then 70, 60, 80. The sorted sequence is the inorder traversal, and 50, 30, 70, 20, ... is level order.
Answer checked How we write and check questions
Discussion