The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+11 votes
549 views

If the binary tree in figure is traversed in inorder, then the order in which the nodes will be visited is ______

asked in DS by Veteran (68.8k points)
retagged by | 549 views
@ arjun sir if this situation occurs in gate exam then what we do...????

is there any default case..???

3 Answers

+15 votes
Best answer
$4 \ 1 \ 6 \ 7 \ 3 \ 2 \ 5 \ 8$
answered by Boss (6.3k points)
edited by
Why node 5 is right child it can be both left or right child?
by default we consider node 5 as left child/.why here right

@Arjun Sir Isnt order cannt  be 41672583 ? Here nothing is mentioned whether 3 child subtree is in left or right.

 

yes, guess the pic is wrong and slanting edge was made straight,
for 3 ary is it 41673258 ?
+11 votes
Two ans possible as the fig is little ambiguous

Case 1:- if 5 is LHS of 3

Inorder:--4 1 6 7 2 5 8 3

Case 2:- if 5 is RHS of 3

inorder :- 4 1 6 7  3 2 5 8
answered by Veteran (22.7k points)
0 votes
41673258 is traversing possible for this problem
answered by Boss (9.5k points)


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

32,330 questions
39,146 answers
108,247 comments
36,501 users