The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+15 votes
2.2k views

Suppose the numbers $7, 5, 1, 8, 3, 6, 0, 9, 4, 2$ are inserted in that order into an initially empty binary search tree. The binary search tree uses the usual ordering on natural numbers. What is the in-order traversal sequence of the resultant tree?

  1. $7 \ 5  \ 1 \ 0 \ 3 \ 2 \ 4 \ 6 \ 8 \ 9$

  2. $0 \ 2 \ 4 \ 3 \ 1 \ 6 \ 5  \ 9  \ 8  \ 7$

  3. $0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7 \ 8 \ 9$

  4. $9 \ 8 \ 6 \ 4  \ 2  \ 3 \ 0 \ 1 \ 5 \ 7$

asked in DS by Veteran (59.9k points)
edited by | 2.2k views

2 Answers

+22 votes
Best answer

In-order traversal returns the elements in sorted order.

Therefore, it's option C

answered by Junior (579 points)
edited by
+1 vote

Inorder traversal

  1. First, visit all the nodes in the left subtree
  2. Then the root node
  3. Visit all the nodes in the right subtree

answered by (123 points)
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
47,881 questions
52,233 answers
182,128 comments
67,653 users