<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Binary-Search-Tree on</title><link>https://h30306.github.io/blog/tags/binary-search-tree/</link><description>Recent content in Binary-Search-Tree on</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>hwork0511@gmail.com (Wei Yi Chung)</managingEditor><webMaster>hwork0511@gmail.com (Wei Yi Chung)</webMaster><copyright>© 2026 Wei Yi Chung</copyright><lastBuildDate>Sun, 25 Oct 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://h30306.github.io/blog/tags/binary-search-tree/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 449: Serialize and Deserialize BST</title><link>https://h30306.github.io/blog/leetcode/leetcode-449/</link><pubDate>Sun, 25 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-449/</guid><description>LeetCode 449 note: for a BST, pre-order without null markers is enough; deserialize recursively with bounds in O(n)</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-449/featured.png"/></item><item><title>LeetCode 450: Delete Node in a BST</title><link>https://h30306.github.io/blog/leetcode/leetcode-450/</link><pubDate>Sun, 25 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-450/</guid><description>LeetCode 450 note: once the node is found: with zero or one child, splice the child in; with two, copy the right subtree&amp;rsquo;s minimum and delete that node</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-450/featured.png"/></item><item><title>LeetCode 99: Recover Binary Search Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-99/</link><pubDate>Sun, 25 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-99/</guid><description>LeetCode 99 note: find the inversions in the in-order sequence: the earlier node of the first inversion and the later node of the last one were swapped</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-99/featured.png"/></item><item><title>LeetCode 173: Binary Search Tree Iterator</title><link>https://h30306.github.io/blog/leetcode/leetcode-173/</link><pubDate>Sat, 24 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-173/</guid><description>LeetCode 173 note: flattening to an array is simple but uses O(n) space; the follow-up keeps the left spine on a stack for amortized O(1) and O(h) space</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-173/featured.png"/></item><item><title>LeetCode 701: Insert into a Binary Search Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-701/</link><pubDate>Sat, 24 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-701/</guid><description>LeetCode 701 note: walk down the BST to an empty spot and attach the new node; an empty tree must return the new node</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-701/featured.png"/></item><item><title>LeetCode 1373: Maximum Sum BST in Binary Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-1373/</link><pubDate>Thu, 10 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-1373/</guid><description>LeetCode 1373 note: a post-order traversal returns (sum, min, max, is_bst); a node roots a BST when the left max &amp;lt; its value &amp;lt; the right min</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1373/featured.png"/></item><item><title>LeetCode 109: Convert Sorted List to Binary Search Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-109/</link><pubDate>Sat, 19 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-109/</guid><description>LeetCode 109 note: take the middle found with fast and slow pointers as the root and recurse on both halves; the height balances naturally</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-109/featured.png"/></item><item><title>LeetCode 230: Kth Smallest Element in a BST</title><link>https://h30306.github.io/blog/leetcode/leetcode-230/</link><pubDate>Sat, 29 Oct 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-230/</guid><description>LeetCode 230 note: a BST&amp;rsquo;s in-order traversal is ascending, so stop an iterative in-order walk at the k-th node</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-230/featured.png"/></item><item><title>LeetCode 98: Validate Binary Search Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-98/</link><pubDate>Sat, 29 Oct 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-98/</guid><description>LeetCode 98 note: every node has a valid range (low, high); going left the upper bound becomes the node and going right the lower bound does; comparing parent and child is not enough</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-98/featured.png"/></item><item><title>LeetCode 938: Range Sum of BST</title><link>https://h30306.github.io/blog/leetcode/leetcode-938/</link><pubDate>Mon, 26 Sep 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-938/</guid><description>LeetCode 938 note: prune with the BST order, going only right below low and only left above high, adding nodes inside the range</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-938/featured.png"/></item><item><title>LeetCode 897: Increasing Order Search Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-897/</link><pubDate>Sun, 25 Sep 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-897/</guid><description>LeetCode 897 note: in-order traversal appending nodes to a right-only chain with left children cleared; keep the dummy separate from the moving tail</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-897/featured.png"/></item><item><title>LeetCode 783: Minimum Distance Between BST Nodes</title><link>https://h30306.github.io/blog/leetcode/leetcode-783/</link><pubDate>Tue, 06 Sep 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-783/</guid><description>LeetCode 783 note: a BST&amp;rsquo;s in-order is ascending, so the minimum difference is between in-order neighbors; remember the previous value and compare</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-783/featured.png"/></item><item><title>LeetCode 700: Search in a Binary Search Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-700/</link><pubDate>Wed, 31 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-700/</guid><description>LeetCode 700 note: go left when the node is larger, right when smaller, and return the node when found</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-700/featured.png"/></item><item><title>LeetCode 703: Kth Largest Element in a Stream</title><link>https://h30306.github.io/blog/leetcode/leetcode-703/</link><pubDate>Wed, 31 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-703/</guid><description>LeetCode 703 note: keep a min-heap of size k; its top is the k-th largest</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-703/featured.png"/></item><item><title>LeetCode 501: Find Mode in Binary Search Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-501/</link><pubDate>Thu, 25 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-501/</guid><description>LeetCode 501 note: a BST&amp;rsquo;s in-order is sorted, so equal values are contiguous; count the current run during in-order, resetting the answer on a new maximum and appending on a tie</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-501/featured.png"/></item><item><title>LeetCode 530: Minimum Absolute Difference in BST</title><link>https://h30306.github.io/blog/leetcode/leetcode-530/</link><pubDate>Thu, 25 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-530/</guid><description>LeetCode 530 note: a BST&amp;rsquo;s in-order is ascending, so the minimum difference is between in-order neighbors; remember the previous value and compare</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-530/featured.png"/></item><item><title>LeetCode 235: Lowest Common Ancestor of a Binary Search Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-235/</link><pubDate>Mon, 22 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-235/</guid><description>LeetCode 235 note: go left when both p and q are smaller, right when both are larger; otherwise (split, or one is the node itself) this node is the LCA</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-235/featured.png"/></item><item><title>LeetCode 108: Convert Sorted Array to Binary Search Tree</title><link>https://h30306.github.io/blog/leetcode/leetcode-108/</link><pubDate>Tue, 16 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-108/</guid><description>LeetCode 108 note: the middle element becomes the root and each half recurses; the halves differ by at most one, so the tree is balanced</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-108/featured.png"/></item></channel></rss>