跳转至

树与二叉树相关算法题

  1. 与树有关的历年真题

【2014】:考察带权路径长度,Acwing3766. 二叉树的带权路径长度

【2017】考察深度优先搜索与递归AcWing 3765. 表达式树

【2022】:本题考察二叉搜索树的性质  力扣 98. 验证二叉搜索树

  1. leetcode推荐习题

先把灵神视频对应习题和课后习题刷了

对应习题及课后习题:

课上习题:

课后习题:

课上习题:

课后习题:

课上习题:

课上习题:

课后习题:

题目 链接 方法 考察年份 推荐指数
144. 二叉树的前序遍历 https://leetcode.cn/problems/binary-tree-preorder-traversal/ ①递归 ②迭代 ③Morris 遍历 ⭐️⭐️⭐️⭐️⭐️
94. 二叉树的中序遍历 https://leetcode.cn/problems/binary-tree-inorder-traversal/ ①递归 ②迭代 ③Morris 遍历 ⭐️⭐️⭐️⭐️⭐️
145. 二叉树的后序遍历 https://leetcode.cn/problems/binary-tree-postorder-traversal/ ①递归 ②迭代 ③Morris 遍历 ⭐️⭐️⭐️⭐️⭐️
102. 二叉树的层序遍历 https://leetcode.cn/problems/binary-tree-level-order-traversal/ ①广度优先搜索 ⭐️⭐️⭐️⭐️⭐️
107. 二叉树的层序遍历 II https://leetcode.cn/problems/binary-tree-level-order-traversal-ii/ ①广度优先搜索 ⭐️⭐️⭐️
103. 二叉树的锯齿形层序遍历 https://leetcode.cn/problems/binary-tree-zigzag-level-order-traversal/ ①广度优先搜索 ⭐️⭐️⭐️
199. 二叉树的右视图 https://leetcode.cn/problems/binary-tree-right-side-view/description/ ①广度优先搜索 ②深度优先搜索 ⭐️⭐️⭐️⭐️⭐️
404. 左叶子之和 https://leetcode.cn/problems/sum-of-left-leaves/ ①广度优先搜索 ②深度优先搜索 ⭐️⭐️⭐️⭐️
104. 二叉树的最大深度 https://leetcode.cn/problems/maximum-depth-of-binary-tree/ ①广度优先搜索 ②深度优先搜索 ⭐️⭐️⭐️⭐️
111. 二叉树的最小深度 https://leetcode.cn/problems/minimum-depth-of-binary-tree/ ①广度优先搜索 ②深度优先搜索 ⭐️⭐️⭐️
101. 对称二叉树 https://leetcode.cn/problems/symmetric-tree/ ①递归 ②迭代 ③广度优先搜索 ⭐️⭐️⭐️
100. 相同的树 https://leetcode.cn/problems/same-tree/ ①递归 ②迭代 ③广度优先搜索 ⭐️⭐️⭐️
98. 验证二叉搜索树 https://leetcode.cn/problems/validate-binary-search-tree/ ①递归 ②中序遍历 2022 ⭐️⭐️⭐️⭐️⭐️
108. 将有序数组转换为二叉搜索树 https://leetcode.cn/problems/convert-sorted-array-to-binary-search-tree/description/ ①中序遍历 ⭐️⭐️⭐️⭐️⭐️
109. 有序链表转换二叉搜索树 https://leetcode.cn/problems/convert-sorted-list-to-binary-search-tree/ ①分治 ②分治 + 中序遍历优化 ⭐️⭐️⭐️
230. 二叉搜索树中第K小的元素 https://leetcode.cn/problems/kth-smallest-element-in-a-bst/ ①中序遍历 ⭐️⭐️⭐️⭐️⭐️
110. 平衡二叉树 https://leetcode.cn/problems/balanced-binary-tree/ ①自顶向下的递归 ②自底向上的递归 ⭐️⭐️⭐️⭐️
958. 二叉树的完全性检验 https://leetcode.cn/problems/check-completeness-of-a-binary-tree/description/ ①广度优先搜索 ⭐️⭐️⭐️⭐️⭐️