map遍历顺序和保存顺序_树遍历–顺序,预顺序和后顺序

map遍历顺序和保存顺序

Here you will learn about tree traversal with program example.

在这里,您将通过程序示例了解有关树遍历的信息。

Tree is a subset of Graph data structure where the number of edges are exactly one less than the number of vertices (nodes). We can call any graph a tree if it does not have any cycle (closed loop).

是图数据结构的子集,其中边的数量比顶点(节点)的数量少一。 如果任何图没有任何循环(闭环),我们可以称其为树。

Tree traversal refers to the process of visiting each node of the tree at least once. Unlike basic linear data structures like arrays, linked list, stack and queue where there was only one way of traversing, trees can be traversed in different ways.

树遍历是指至少访问树的每个节点一次的过程。 与只有一种遍历方式的基本线性数据结构(如数组,链表,堆栈和队列)不同,可以以不同的方式遍历树。

We can categorize the tree traversal into two categories:

我们可以将树遍历分为两类:

  1. Breadth-first Traversal

    广度优先遍历
  2. Depth-first Traversal

    深度优先遍历

深度优先遍历 (Depth-first Traversal)

In Depth-first traversal, the direction of traversal is from top to bottom. As the name suggests, we traverse to the depth of the tree starting from the root node of the tree. Based on the way of traversal, we have these three types of traversals:

在深度优先遍历中,遍历的方向是从上到下。 顾名思义,我们从树的根节点开始遍历树的深度。 基于遍历的方式,我们有以下三种遍历类型:

  • In-order Traversal

    有序遍历
  • Pre-order Traversal

    预购遍历
  • Post-order Traversal

    订单遍历

These three types of traversal are usually performed on binary trees. Binary tree is a special type of tree in which a parent node can have at most two child nodes. Binary Search Tree (BST) is a special binary tree where every smaller value is on the left

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值