Update README.md

This commit is contained in:
bt3gl 2023-07-29 15:37:01 -07:00 committed by GitHub
parent ea039f5514
commit 5ec8587911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,14 +9,21 @@
<br> <br>
* if the depth of the tree is too large, stack overflow might happen, therefore iterative solutions might be better. * **breath-first search**:
* **in-order** are similar to breath-first search (level order problems) - similar to pre-order, but work with queue (level order problem)
- work with queues * **depth-first search**:
* **pre-order** is top-down (parameters are passed down to children). * if the depth of the tree is too large, stack overflow might happen, therefore iterative solutions might be better.
- work with stacks * work with stacks
* **post-order** is a bottom-up solution (if you know the answer of the children, can you concatenate the answer of the nodes?): * **in-order**:
- 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. * left -> node -> right
- 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. * **pre-order**
* node -> left -> right
* top-down (parameters are passed down to children).
* **post-order**
* left -> right -> node
* bottom-up solution (if you know the answer of the children, can you concatenate the answer of the nodes?):
- 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.
- 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.
<br> <br>