二叉树遍历结果推二叉树
In this article, we shall look into how we can perform a Binary Tree Traversal using different methods.
在本文中,我们将研究如何使用不同的方法执行二叉树遍历。
A Binary Tree is a data structure where every node has at most two children. We call the topmost node as the Root node.
二叉树是一种数据结构,其中每个节点最多具有两个子节点。 我们将最顶层的节点称为“ 根”节点。
Since it could have two children, we could move across the Binary Tree in different ways. Here, we will discuss the three most commonly used methods for traversal, namely:
由于它可以有两个孩子,因此我们可以以不同的方式在二叉树上移动。 在这里,我们将讨论三种最常用的遍历方法,即:
- PreOrder Traversal 预购遍历
- InOrder Traversal 有序遍历
- PostOrder Traversal 后订单遍历
Let us consider the below Binary Tree and try to traverse it using the above methods.
让我们考虑下面的二叉树,并尝试使用上述方法遍历它。
1.二叉树预遍历 (1. Binary Tree PreOrder Traversal)
In a PreOrder traversal, the nodes are traversed accordin