adding level order animation

This commit is contained in:
Jidong Xiao
2025-03-24 18:13:31 -04:00
committed by JamesFlare
parent ba74c7efbe
commit e005a62828
2 changed files with 77 additions and 3 deletions

View File

@@ -62,8 +62,6 @@ We can also implement operator++ for the ds_set iterator without using the paren
- Write an algorithm to print the nodes in the tree one tier at a time, that is, in a breadth-first manner.
```cpp
BFS code discussed in class
void breadth_first_traverse(Node* root)
{
int level=0;
@@ -93,6 +91,10 @@ We can also implement operator++ for the ds_set iterator without using the paren
- What is the best/average/worst-case running time of this algorithm? What is the best/average/worst-case
memory usage of this algorithm? Give a specific example tree that illustrates each case.
- Run [this bfs_main.cpp program](bfs_main.cpp) to test the above function.
- Play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/trees/level_order/index.html) to understand how this works.
## 20.5 Height and Height Calculation Algorithm
- The height of a node in a tree is the length of the longest path down the tree from that node to a leaf node. The height of a tree with only one node (the root node) is 1. The height of an empty tree (a tree with no nodes) is 0.
@@ -189,7 +191,7 @@ Draw picture of each case!
- Then we recursively apply erase to remove that node — which is guaranteed to have at most one child.
play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/trees/delete_node/index.html) to understand how this works.
Play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/trees/delete_node/index.html) to understand how this works.
Exercise: Write a recursive version of erase.