in DS edited by
3,253 views
16 votes

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

in DS edited by
3.3k views

1 comment

@ arjun sir if this situation occurs in gate exam then what we do...????

is there any default case..???
0

Subscribe to GO Classes for GATE CSE 2022

5 Answers

23 votes
 
Best answer

During the in-order traversal algorithm, the left subtree is explored first, followed by root, and finally nodes on the right subtree.

In order traversal is $:4 \ 1 \ 6 \ 7 \ 3 \ 2 \ 5 \ 8.$

edited by

6 Comments

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
2

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

3
yes, guess the pic is wrong and slanting edge was made straight,
6
for 3 ary is it 41673258 ?
0
“then the order in which the nodes will be visited is … “ shouldn’t this imply the order in which the nodes are “visited” and not “printed”.  

4 1 6 7 3 2 5 8 is the In order

But here it is asking the order in which the nodes are visited, and not printed. So according to me the answer should be 7 1 4 6 3 5 2 8 (basically pre order)

Can someone please clear this doubt?
0
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

1 comment

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??

0
2 votes
41673258 is traversing possible for this problem
0 votes

 

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

0 votes
4,1,6,7,3,2,5,8 i did it in mind

Related questions

Ask
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