<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Binary Tree on Yosgi</title><link>https://yosgi.github.io/en/tags/binary-tree/</link><description>Recent content in Binary Tree on Yosgi</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 08 Oct 2026 01:31:25 +0000</lastBuildDate><atom:link href="https://yosgi.github.io/en/tags/binary-tree/index.xml" rel="self" type="application/rss+xml"/><item><title>1104-Binary Tree Pathfinding</title><link>https://yosgi.github.io/en/post/1104-binary-tree-pathfinding/</link><pubDate>Thu, 29 Jul 2021 00:00:00 +1200</pubDate><guid>https://yosgi.github.io/en/post/1104-binary-tree-pathfinding/</guid><description>Finding the path in a zigzag-labeled binary tree using the symmetry of each level's numbering.</description></item><item><title>865 - Minimum subtree with all deepest nodes</title><link>https://yosgi.github.io/en/post/865-minimum-subtree-with-all-deepest-nodes/</link><pubDate>Sun, 21 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/865-minimum-subtree-with-all-deepest-nodes/</guid><description>Finding the smallest subtree containing all deepest nodes with a single bottom-up recursion that returns each subtree's depth.</description></item><item><title>783-Binary Search Tree Node Minimum Distance</title><link>https://yosgi.github.io/en/post/783-binary-search-tree-node-minimum-distance/</link><pubDate>Thu, 18 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/783-binary-search-tree-node-minimum-distance/</guid><description>Finding the minimum distance between BST nodes using the ordered property of in-order traversal.</description></item><item><title>814-Binary Tree Pruning</title><link>https://yosgi.github.io/en/post/814-binary-tree-pruning/</link><pubDate>Wed, 17 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/814-binary-tree-pruning/</guid><description>Pruning subtrees that contain no 1 with post-order traversal, using a dummy parent so the root can also be pruned.</description></item><item><title>1448-Count the number of good nodes in a binary tree</title><link>https://yosgi.github.io/en/post/1448-count-the-number-of-good-nodes-in-a-binary-tree/</link><pubDate>Wed, 17 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/1448-count-the-number-of-good-nodes-in-a-binary-tree/</guid><description>Notes on counting good nodes in a binary tree using DFS with a running max.</description></item><item><title>1325-Delete the leaf node of the given value</title><link>https://yosgi.github.io/en/post/1325-delete-the-leaf-node-of-the-given-value/</link><pubDate>Wed, 17 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/1325-delete-the-leaf-node-of-the-given-value/</guid><description>Post-order traversal approach to delete target-valued leaf nodes using a dummy root.</description></item><item><title>1022 - the sum of the binary numbers from root to leaf</title><link>https://yosgi.github.io/en/post/1022-the-sum-of-the-binary-numbers-from-root-to-leaf/</link><pubDate>Wed, 17 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/1022-the-sum-of-the-binary-numbers-from-root-to-leaf/</guid><description>Summing root-to-leaf binary numbers with top-down pre-order traversal.</description></item><item><title>563-Slope of Binary Tree</title><link>https://yosgi.github.io/en/post/563-slope-of-binary-tree/</link><pubDate>Tue, 16 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/563-slope-of-binary-tree/</guid><description>Computing the total tilt of a binary tree with recursion that returns each subtree's sum.</description></item><item><title>129-Find the sum of numbers from the root node to the leaf node</title><link>https://yosgi.github.io/en/post/129-find-the-sum-of-numbers-from-the-root-node-to-the-leaf-node/</link><pubDate>Tue, 16 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/129-find-the-sum-of-numbers-from-the-root-node-to-the-leaf-node/</guid><description>Summing all root-to-leaf numbers with top-down pre-order DFS, carrying the running value down each path.</description></item><item><title>124-Maximum Path Sum in a Binary Tree</title><link>https://yosgi.github.io/en/post/124-maximum-path-sum-in-a-binary-tree/</link><pubDate>Mon, 15 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/124-maximum-path-sum-in-a-binary-tree/</guid><description>Finding the maximum path sum in a binary tree with recursion that returns each node's best downward contribution.</description></item><item><title>99-Restore Binary Search Tree</title><link>https://yosgi.github.io/en/post/99-restore-binary-search-tree/</link><pubDate>Sat, 13 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/99-restore-binary-search-tree/</guid><description>Restoring a BST with two swapped nodes by locating them during an in-order traversal.</description></item><item><title>98-Verify Binary Search Tree</title><link>https://yosgi.github.io/en/post/98-verify-binary-search-tree/</link><pubDate>Sat, 13 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/98-verify-binary-search-tree/</guid><description>Validating a binary search tree by exploiting the increasing order of its in-order traversal.</description></item><item><title>863-All nodes with distance -K- in a binary tree</title><link>https://yosgi.github.io/en/post/863-all-nodes-with-distance-k-in-a-binary-tree/</link><pubDate>Sat, 13 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/863-all-nodes-with-distance-k-in-a-binary-tree/</guid><description>Finding all nodes at distance K by first adding parent links with DFS, then searching outward from the target.</description></item><item><title>662-Binary Tree Maximum Width</title><link>https://yosgi.github.io/en/post/662-binary-tree-maximum-width/</link><pubDate>Sat, 13 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/662-binary-tree-maximum-width/</guid><description>Computing the maximum width of a binary tree with BFS, tracking each node's position index within its level.</description></item><item><title>222-Number of nodes in a complete binary tree</title><link>https://yosgi.github.io/en/post/222-number-of-nodes-in-a-complete-binary-tree/</link><pubDate>Sat, 13 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/222-number-of-nodes-in-a-complete-binary-tree/</guid><description>Counting nodes in a complete binary tree using left/right subtree depths instead of a full DFS.</description></item><item><title>669-Pruning a Binary Search Tree</title><link>https://yosgi.github.io/en/post/669-pruning-a-binary-search-tree/</link><pubDate>Thu, 11 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/669-pruning-a-binary-search-tree/</guid><description>Trimming a BST to a value range by recursing into the correct branch using the BST bounds.</description></item><item><title>450-Delete a node in a binary search tree</title><link>https://yosgi.github.io/en/post/450-delete-a-node-in-a-binary-search-tree/</link><pubDate>Thu, 11 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/450-delete-a-node-in-a-binary-search-tree/</guid><description>Deleting a node from a binary search tree by locating it via the BST property, then handling the three deletion cases.</description></item><item><title>116-Fill in the next right node pointer of each node</title><link>https://yosgi.github.io/en/post/116-fill-in-the-next-right-node-pointer-of-each-node/</link><pubDate>Wed, 10 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/116-fill-in-the-next-right-node-pointer-of-each-node/</guid><description>Connecting each node to its right neighbor per level, reusing the previous layer's links to reach constant space.</description></item><item><title>1008-Pre-order traversal to construct a binary search tree</title><link>https://yosgi.github.io/en/post/1008-pre-order-traversal-to-construct-a-binary-search-tree/</link><pubDate>Wed, 10 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/1008-pre-order-traversal-to-construct-a-binary-search-tree/</guid><description>Constructing a binary search tree from its pre-order sequence by recursively inserting each value.</description></item><item><title>894-All possible full binary trees</title><link>https://yosgi.github.io/en/post/894-all-possible-full-binary-trees/</link><pubDate>Sun, 07 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/894-all-possible-full-binary-trees/</guid><description>Generating all possible full binary trees with recursion that combines left and right subtree counts (DP).</description></item><item><title>297-Serialization and Deserialization of Binary Trees</title><link>https://yosgi.github.io/en/post/297-serialization-and-deserialization-of-binary-trees/</link><pubDate>Thu, 04 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/297-serialization-and-deserialization-of-binary-trees/</guid><description>Serializing a binary tree with BFS and deserializing it using parent/child index relationships.</description></item><item><title>1372-Longest Alternating Path in a Binary Tree</title><link>https://yosgi.github.io/en/post/1372-longest-alternating-path-in-a-binary-tree/</link><pubDate>Mon, 01 Mar 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/1372-longest-alternating-path-in-a-binary-tree/</guid><description>Finding the longest zigzag path in a binary tree with DFS that tracks direction and length, handling the boundary cases.</description></item><item><title>Summary of Binary Trees</title><link>https://yosgi.github.io/en/post/summary-of-binary-trees/</link><pubDate>Sun, 28 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/summary-of-binary-trees/</guid><description>Notes on binary tree traversal — why DFS uses a stack and BFS a queue, with reusable pre/in/post-order and level-order templates.</description></item><item><title>102 - Level-order Traversal of a Binary Tree</title><link>https://yosgi.github.io/en/post/102-level-order-traversal-of-a-binary-tree/</link><pubDate>Sun, 28 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/102-level-order-traversal-of-a-binary-tree/</guid><description>Techniques and examples for breadth-first (level-order) traversal of binary trees.</description></item><item><title>145-Post-order traversal of a binary tree</title><link>https://yosgi.github.io/en/post/145-post-order-traversal-of-a-binary-tree/</link><pubDate>Fri, 26 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/145-post-order-traversal-of-a-binary-tree/</guid><description>Post-order binary tree traversal, both recursively and iteratively with a stack.</description></item><item><title>94-In-order traversal of a binary tree</title><link>https://yosgi.github.io/en/post/94-in-order-traversal-of-a-binary-tree/</link><pubDate>Thu, 25 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/94-in-order-traversal-of-a-binary-tree/</guid><description>In-order binary tree traversal, both recursively and iteratively with an explicit stack.</description></item><item><title>144-Pre-order traversal of a binary tree</title><link>https://yosgi.github.io/en/post/144-pre-order-traversal-of-a-binary-tree/</link><pubDate>Thu, 25 Feb 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/144-pre-order-traversal-of-a-binary-tree/</guid><description>Iterative pre-order binary tree traversal using an explicit stack.</description></item><item><title>105-Constructing a binary tree from pre-order and in-order traversal sequences-1</title><link>https://yosgi.github.io/en/post/105-constructing-a-binary-tree-from-pre-order-and-in-order-traversal-sequences-1/</link><pubDate>Wed, 27 Jan 2021 00:00:00 +1300</pubDate><guid>https://yosgi.github.io/en/post/105-constructing-a-binary-tree-from-pre-order-and-in-order-traversal-sequences-1/</guid><description>Reconstructing a binary tree from its pre-order and in-order sequences by recursively splitting on the root.</description></item></channel></rss>