Binary Search Tree
Preorder Traversal
|
|
Inorder Traversal
|
|
Postorder Traversal (*)
|
|
DFS
- consider root.right first v.s. root.left first
- avoid using left, right, i, next as variables (use start, end …)
- DFS + memorization to optimize your solutions (https://leetcode.com/problems/word-break-ii/description/) (when there are many repeated steps)
|
|
BFS
|
|
Heap (Also know as priority queue)
In Python, queue.PriorityQueue is a partial wrapper around the heapq class.
In other words, a queue.PriorityQueue is actually a heapq, placed in the queue module with a couple of renamed methods to make the heapq easier to use, much like a regular queue.
Trie (prefix tree)
|
|