This post contains notes for common algorithms and data structures.
Graph
Pattern Searching
Rabin–Karp Algorithm
Knuth–Morris–Pratt Algorithm
Boyer–Moore Algorithm
Tree
Traversal
Morris Traversal
Ref: Morris Traversal方法遍历二叉树(非递归,不用栈,O(1)空间)
In order to achieve O(1) space complexity and O(n) time complexity for traversal problem, we could not use recursion and stack+iterative methods. Morris Traversal link last node of subtree traversal to the next node to be traversed (the current root).