98. Validate Binary Search Tree
給定root
二叉樹的 ,確定它是否是有效的二叉搜索樹 (BST)。
一個有效的 BST定義如下:
- 左邊子樹節點的僅包含鍵小於節點鍵的節點。
- 節點的右子樹僅包含鍵大於節點鍵的節點。
- 左右子樹也必須是二叉搜索樹。
recursively


Inorder- recursively的解法

938. Range Sum of BST
Preorder-Iteratively 的解法

Postorder-recursively的解法


95. Unique Binary Search Trees II
可能的組合方法
當n=3時可以重複去用剛剛n=1和n=2的組合

recursively的解法


144. Binary Tree Preorder Traversal
Morris的解法
- Morris-Preorder-Iteratively 的解法

Preorder-Iteratively 的解法

94. Binary Tree Inorder Traversal
Inorder-Iteratively 的解法
這一題跟就是144題的Inorder做法,只需要把output.append(root.val)換到else條件中就好


145. Binary Tree Postorder Traversal
Postorder-Iteratively 的解法
以下和上面Preorder-Iteratively 的解法只差在先遍歷右在遍歷左,之後再用reversed()去返回列表的逆序迭代器
