The total traversal combinations, possible for the below mentioned Sample Tree are
DLR, LDR, LRD, DRL, RDL, RLD
Sample Tree [ D=root, L= LeftNode, R= RightNode ]
D
/ \
L R
PreOrder: DLR
InOrder: LDR
PostOrder: LRD
Why other combinations like DRL, RDL & RLD never considered?
In a binary tree, the first child is on the left and the second child is on the right. In the combinations, DRL, RDL, and RLD , R
comes before L
which is against the concept of Tree and therefore they are never considered for the traversal of a binary tree.
Check this to learn more about the Tree data structure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.