The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+12 votes
863 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 (59.7k points)
retagged by | 863 views
0
@ arjun sir if this situation occurs in gate exam then what we do...????

is there any default case..???

4 Answers

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

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

+5
yes, guess the pic is wrong and slanting edge was made straight,
0
for 3 ary is it 41673258 ?
+12 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 Boss (23.1k points)
0

In the given image clearly see $5$ is a right child of $3,$why you take $5$ is left a child of $3$, i mean two cases??

+2 votes
41673258 is traversing possible for this problem
answered by Loyal (7.4k points)
0 votes

 

so this is inorder traversal 4,1,6,7,3,2,5,8

answered by Junior (891 points)

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

44,253 questions
49,750 answers
164,102 comments
65,847 users