Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 48720ad

Browse files
Update README.md
1 parent 1caaed5 commit 48720ad

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

trees_and_graphs/README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1-
## trees
1+
## trees and graphs
22

33
<br>
44

55

6+
---
7+
8+
### tree tranversals
9+
10+
<br>
11+
12+
* if the depth of the tree is too large, stack overflow might happen, therefore iterative solutions might be better.
13+
* **in-order** are similar to breath-first search (level order problems)
14+
- work with queues
15+
* **pre-order** is top-down (parameters are passed down to children).
16+
- work with stacks
17+
* **post-order** is a bottom-up solution (if you know the answer of the children, can you concatenate the answer of the nodes?):
18+
- deletion process is always post-order: when you delete a node, you will delete its left child and its right child before you delete the node itself.
19+
- also, post-order is used in mathematical expressions as it's easier to write a program to parse a post-order expression. using a stack, each time when you meet a operator, you can just pop 2 elements from the stack, calculate the result and push the result back into the stack.
20+
21+
22+
<br>
23+
24+
---
25+
626
### `Tree.py`
727

828
<br>

0 commit comments

Comments
 (0)