<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Binary Tree on Yosgi</title><link>https://yosgi.github.io/zh/tags/binary-tree/</link><description>Recent content in Binary Tree on Yosgi</description><generator>Hugo</generator><language>zh</language><lastBuildDate>Thu, 08 Oct 2026 01:31:26 +0000</lastBuildDate><atom:link href="https://yosgi.github.io/zh/tags/binary-tree/index.xml" rel="self" type="application/rss+xml"/><item><title>1104-二叉树寻路</title><link>https://yosgi.github.io/zh/post/1104-%E4%BA%8C%E5%8F%89%E6%A0%91%E5%AF%BB%E8%B7%AF/</link><pubDate>Thu, 29 Jul 2021 00:00:00 +1200</pubDate><guid>https://yosgi.github.io/zh/post/1104-%E4%BA%8C%E5%8F%89%E6%A0%91%E5%AF%BB%E8%B7%AF/</guid><description>利用之字形编号二叉树每层的对称性直接推算路径。</description></item><item><title>865-具有所有最深节点的最小子树</title><link>https://yosgi.github.io/zh/post/865-%E5%85%B7%E6%9C%89%E6%89%80%E6%9C%89%E6%9C%80%E6%B7%B1%E8%8A%82%E7%82%B9%E7%9A%84%E6%9C%80%E5%B0%8F%E5%AD%90%E6%A0%91/</link><pubDate>Sun, 21 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/865-%E5%85%B7%E6%9C%89%E6%89%80%E6%9C%89%E6%9C%80%E6%B7%B1%E8%8A%82%E7%82%B9%E7%9A%84%E6%9C%80%E5%B0%8F%E5%AD%90%E6%A0%91/</guid><description>用一次自底向上的递归返回子树深度，找到包含所有最深节点的最小子树。</description></item><item><title>783-二叉搜索树节点最小距离</title><link>https://yosgi.github.io/zh/post/783-%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E8%8A%82%E7%82%B9%E6%9C%80%E5%B0%8F%E8%B7%9D%E7%A6%BB/</link><pubDate>Thu, 18 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/783-%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E8%8A%82%E7%82%B9%E6%9C%80%E5%B0%8F%E8%B7%9D%E7%A6%BB/</guid><description>利用二叉搜索树中序遍历的有序性求相邻节点的最小差值。</description></item><item><title>814-二叉树剪枝</title><link>https://yosgi.github.io/zh/post/814-%E4%BA%8C%E5%8F%89%E6%A0%91%E5%89%AA%E6%9E%9D/</link><pubDate>Wed, 17 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/814-%E4%BA%8C%E5%8F%89%E6%A0%91%E5%89%AA%E6%9E%9D/</guid><description>后序遍历剪去不含 1 的子树，并用虚拟父节点使根也能被剪。</description></item><item><title>1448-统计二叉树中好节点的数目</title><link>https://yosgi.github.io/zh/post/1448-%E7%BB%9F%E8%AE%A1%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E5%A5%BD%E8%8A%82%E7%82%B9%E7%9A%84%E6%95%B0%E7%9B%AE/</link><pubDate>Wed, 17 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/1448-%E7%BB%9F%E8%AE%A1%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E5%A5%BD%E8%8A%82%E7%82%B9%E7%9A%84%E6%95%B0%E7%9B%AE/</guid><description>用 DFS 维护路径上的当前最大值，统计二叉树中的好节点数目。</description></item><item><title>1325-删除给定值的叶子节点</title><link>https://yosgi.github.io/zh/post/1325-%E5%88%A0%E9%99%A4%E7%BB%99%E5%AE%9A%E5%80%BC%E7%9A%84%E5%8F%B6%E5%AD%90%E8%8A%82%E7%82%B9/</link><pubDate>Wed, 17 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/1325-%E5%88%A0%E9%99%A4%E7%BB%99%E5%AE%9A%E5%80%BC%E7%9A%84%E5%8F%B6%E5%AD%90%E8%8A%82%E7%82%B9/</guid><description>用后序遍历配合虚拟根节点，删除值为目标值的叶子节点。</description></item><item><title>1022-从根到叶的二进制数之和</title><link>https://yosgi.github.io/zh/post/1022-%E4%BB%8E%E6%A0%B9%E5%88%B0%E5%8F%B6%E7%9A%84%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%95%B0%E4%B9%8B%E5%92%8C/</link><pubDate>Wed, 17 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/1022-%E4%BB%8E%E6%A0%B9%E5%88%B0%E5%8F%B6%E7%9A%84%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%95%B0%E4%B9%8B%E5%92%8C/</guid><description>自顶向下前序遍历，累计从根到叶的二进制路径并求和。</description></item><item><title>563-二叉树的坡度</title><link>https://yosgi.github.io/zh/post/563-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%9D%A1%E5%BA%A6/</link><pubDate>Tue, 16 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/563-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%9D%A1%E5%BA%A6/</guid><description>用返回子树和的递归计算二叉树的总坡度。</description></item><item><title>129-求根节点到叶节点数字之和</title><link>https://yosgi.github.io/zh/post/129-%E6%B1%82%E6%A0%B9%E8%8A%82%E7%82%B9%E5%88%B0%E5%8F%B6%E8%8A%82%E7%82%B9%E6%95%B0%E5%AD%97%E4%B9%8B%E5%92%8C/</link><pubDate>Tue, 16 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/129-%E6%B1%82%E6%A0%B9%E8%8A%82%E7%82%B9%E5%88%B0%E5%8F%B6%E8%8A%82%E7%82%B9%E6%95%B0%E5%AD%97%E4%B9%8B%E5%92%8C/</guid><description>自顶向下前序 DFS，沿路径携带累计值，求所有根到叶数字之和。</description></item><item><title>124-二叉树中的最大路径和</title><link>https://yosgi.github.io/zh/post/124-%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E5%A4%A7%E8%B7%AF%E5%BE%84%E5%92%8C/</link><pubDate>Mon, 15 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/124-%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E5%A4%A7%E8%B7%AF%E5%BE%84%E5%92%8C/</guid><description>用递归返回每个节点向下的最大贡献，求二叉树的最大路径和。</description></item><item><title>99-恢复二叉搜索树</title><link>https://yosgi.github.io/zh/post/99-%E6%81%A2%E5%A4%8D%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/</link><pubDate>Sat, 13 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/99-%E6%81%A2%E5%A4%8D%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/</guid><description>利用中序遍历的递增性质定位被交换的两个节点，恢复二叉搜索树。</description></item><item><title>98-验证二叉搜索树</title><link>https://yosgi.github.io/zh/post/98-%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/</link><pubDate>Sat, 13 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/98-%E9%AA%8C%E8%AF%81%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/</guid><description>利用二叉搜索树中序遍历递增的性质来验证其合法性。</description></item><item><title>662-二叉树最大宽度</title><link>https://yosgi.github.io/zh/post/662-%E4%BA%8C%E5%8F%89%E6%A0%91%E6%9C%80%E5%A4%A7%E5%AE%BD%E5%BA%A6/</link><pubDate>Sat, 13 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/662-%E4%BA%8C%E5%8F%89%E6%A0%91%E6%9C%80%E5%A4%A7%E5%AE%BD%E5%BA%A6/</guid><description>用 BFS 并为每个节点记录层内位置下标来计算二叉树的最大宽度。</description></item><item><title>222-完全二叉树的节点个数</title><link>https://yosgi.github.io/zh/post/222-%E5%AE%8C%E5%85%A8%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E8%8A%82%E7%82%B9%E4%B8%AA%E6%95%B0/</link><pubDate>Sat, 13 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/222-%E5%AE%8C%E5%85%A8%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E8%8A%82%E7%82%B9%E4%B8%AA%E6%95%B0/</guid><description>利用完全二叉树左右子树深度的性质统计节点数，避免逐个 DFS。</description></item><item><title>669-修剪二叉搜索树</title><link>https://yosgi.github.io/zh/post/669-%E4%BF%AE%E5%89%AA%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/</link><pubDate>Thu, 11 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/669-%E4%BF%AE%E5%89%AA%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/</guid><description>利用二叉搜索树的边界性质，递归进入正确分支修剪到给定区间。</description></item><item><title>450-删除二叉搜索树中的节点</title><link>https://yosgi.github.io/zh/post/450-%E5%88%A0%E9%99%A4%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E4%B8%AD%E7%9A%84%E8%8A%82%E7%82%B9/</link><pubDate>Thu, 11 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/450-%E5%88%A0%E9%99%A4%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E4%B8%AD%E7%9A%84%E8%8A%82%E7%82%B9/</guid><description>先按二叉搜索树性质定位节点，再分三种情况处理删除。</description></item><item><title>116-填充每个节点的下一个右侧节点指针</title><link>https://yosgi.github.io/zh/post/116-%E5%A1%AB%E5%85%85%E6%AF%8F%E4%B8%AA%E8%8A%82%E7%82%B9%E7%9A%84%E4%B8%8B%E4%B8%80%E4%B8%AA%E5%8F%B3%E4%BE%A7%E8%8A%82%E7%82%B9%E6%8C%87%E9%92%88/</link><pubDate>Wed, 10 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/116-%E5%A1%AB%E5%85%85%E6%AF%8F%E4%B8%AA%E8%8A%82%E7%82%B9%E7%9A%84%E4%B8%8B%E4%B8%80%E4%B8%AA%E5%8F%B3%E4%BE%A7%E8%8A%82%E7%82%B9%E6%8C%87%E9%92%88/</guid><description>逐层把每个节点连到右邻居，利用上一层已有的 next 指针达到常数空间。</description></item><item><title>1008-前序遍历构造二叉搜索树</title><link>https://yosgi.github.io/zh/post/1008-%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86%E6%9E%84%E9%80%A0%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/</link><pubDate>Wed, 10 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/1008-%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86%E6%9E%84%E9%80%A0%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/</guid><description>通过递归依次插入，从前序序列重建二叉搜索树。</description></item><item><title>894-所有可能的满二叉树</title><link>https://yosgi.github.io/zh/post/894-%E6%89%80%E6%9C%89%E5%8F%AF%E8%83%BD%E7%9A%84%E6%BB%A1%E4%BA%8C%E5%8F%89%E6%A0%91/</link><pubDate>Sun, 07 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/894-%E6%89%80%E6%9C%89%E5%8F%AF%E8%83%BD%E7%9A%84%E6%BB%A1%E4%BA%8C%E5%8F%89%E6%A0%91/</guid><description>用递归（动态规划）组合左右子树，生成所有可能的满二叉树。</description></item><item><title>297-二叉树的序列化与反序列化</title><link>https://yosgi.github.io/zh/post/297-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%BA%8F%E5%88%97%E5%8C%96%E4%B8%8E%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96/</link><pubDate>Thu, 04 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/297-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%BA%8F%E5%88%97%E5%8C%96%E4%B8%8E%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96/</guid><description>用 BFS 序列化二叉树，并借助父子节点下标关系反序列化。</description></item><item><title>1372-二叉树中的最长交错路径</title><link>https://yosgi.github.io/zh/post/1372-%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E9%95%BF%E4%BA%A4%E9%94%99%E8%B7%AF%E5%BE%84/</link><pubDate>Mon, 01 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/1372-%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%AD%E7%9A%84%E6%9C%80%E9%95%BF%E4%BA%A4%E9%94%99%E8%B7%AF%E5%BE%84/</guid><description>用 DFS 记录方向与长度求二叉树中最长的交错路径，并处理边界情况。</description></item><item><title>关于二叉树的总结</title><link>https://yosgi.github.io/zh/post/%E5%85%B3%E4%BA%8E%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%80%BB%E7%BB%93/</link><pubDate>Sun, 28 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/%E5%85%B3%E4%BA%8E%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E6%80%BB%E7%BB%93/</guid><description>二叉树遍历总结：为什么 DFS 用栈、BFS 用队列，并给出可复用的前中后序与层序模板。</description></item><item><title>102-二叉树的层序遍历</title><link>https://yosgi.github.io/zh/post/102-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%B1%82%E5%BA%8F%E9%81%8D%E5%8E%86/</link><pubDate>Sun, 28 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/102-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%B1%82%E5%BA%8F%E9%81%8D%E5%8E%86/</guid><description>二叉树层序遍历（BFS），用 null 标记每层结束的迭代与递归两种写法。</description></item><item><title>145-二叉树的后序遍历</title><link>https://yosgi.github.io/zh/post/145-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%90%8E%E5%BA%8F%E9%81%8D%E5%8E%86/</link><pubDate>Fri, 26 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/145-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%90%8E%E5%BA%8F%E9%81%8D%E5%8E%86/</guid><description>二叉树后序遍历的递归写法与借助栈的迭代写法。</description></item><item><title>94-二叉树的中序遍历</title><link>https://yosgi.github.io/zh/post/94-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86/</link><pubDate>Thu, 25 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/94-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86/</guid><description>二叉树中序遍历的递归写法与借助显式栈的迭代写法。</description></item><item><title>144-二叉树的前序遍历</title><link>https://yosgi.github.io/zh/post/144-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86/</link><pubDate>Thu, 25 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/144-%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86/</guid><description>二叉树前序遍历，借助显式栈的迭代实现。</description></item><item><title>105-从前序遍历与中序遍历序列构造二叉树-1</title><link>https://yosgi.github.io/zh/post/105-%E4%BB%8E%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86%E4%B8%8E%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86%E5%BA%8F%E5%88%97%E6%9E%84%E9%80%A0%E4%BA%8C%E5%8F%89%E6%A0%91-1/</link><pubDate>Wed, 27 Jan 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/zh/post/105-%E4%BB%8E%E5%89%8D%E5%BA%8F%E9%81%8D%E5%8E%86%E4%B8%8E%E4%B8%AD%E5%BA%8F%E9%81%8D%E5%8E%86%E5%BA%8F%E5%88%97%E6%9E%84%E9%80%A0%E4%BA%8C%E5%8F%89%E6%A0%91-1/</guid><description>根据前序定位根、中序切分左右子树，递归重建二叉树。</description></item></channel></rss>