Inorder tree traversal: Which definition is correct?

前端 未结 14 1235
轮回少年
轮回少年 2020-12-24 03:42

I have the following text from an academic course I took a while ago about inorder traversal (they also call it pancaking) of a binary tree (not BST):

14条回答
  •  时光说笑
    2020-12-24 04:10

    Hey according to me as mentioned in wiki is correct the sequence for a inorder traversal is left-root-right.

    Till A, B, C, D, E, F i think you have understood already. Now after root F the next node is G that doesn't hav a left node but a right node so as per the rule (left-root-right) its null-g-right. Now I is the right node of G but I has a left node hence the traversal would be GHI. This is correct.

    Hope this helps.

提交回复
热议问题