二叉树上的预排序遍历与深度优先搜索相同吗?

人气:258 发布:2022-10-16 标签: algorithm tree binary-tree depth-first-search preorder

问题描述

在我看来,前序遍历和 DFS 与我们以深度方式遍历到叶节点的两种情况相同.如果我错了,有人可以纠正我吗?

It seems to me like Pre-order traversal and DFS are same as in both the cases we traverse till the leaf node in a depth wise fashion. Could anyone please correct me if I am wrong?

提前致谢!

推荐答案

预购是 DFS 的一种.

Pre-order is one type of DFS.

深度优先遍历有前序、中序和后序三种.

There are three types of depth-first traversal: pre-order, in-order, and post-order.

查看此处了解更多信息.

132