首页 > 编程语言 >LeetCode 二叉树遍历算法题解 All In One

LeetCode 二叉树遍历算法题解 All In One

时间:2022-10-12 12:13:27浏览次数:104  
标签:遍历 题解 节点 二叉树 xgqfrms Root LeetCode

LeetCode 二叉树遍历算法题解 All In One

树的遍历 / Tree Traversal

主要看 根节点 Root 的遍历顺序: 前,中,后

  1. 前序遍历 (Root, Left, Right)
    先访问根节点,然后遍历左子树,最后遍历右子树

  2. 中序遍历 (Left, Root, Right)
    先遍历左子树,然后访问根节点,然后遍历右子树

通常来说,对于二叉搜索树,我们可以通过中序遍历得到一个递增有序序列

  1. 后序遍历 (Left, Right, Root)
    先遍历左子树,然后遍历右子树,最后访问树的根节点



BST / BTS

Binary Search Tree / Binary Tree Search

二叉搜索树 / 二叉树搜索

refs

https://www.cnblogs.com/xgqfrms/p/13710756.html

https://leetcode.cn/explore/learn/card/data-structure-binary-tree/2/traverse-a-tree/7/

https://leetcode.cn/leetbook/read/data-structure-binary-tree/xe17x7/



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载

标签:遍历,题解,节点,二叉树,xgqfrms,Root,LeetCode
From: https://www.cnblogs.com/xgqfrms/p/16784063.html

相关文章