diff --git a/contents/tree_traversal/code/scratch/bfs.svg b/contents/tree_traversal/code/scratch/bfs.svg new file mode 100644 index 000000000..d7cf1e692 --- /dev/null +++ b/contents/tree_traversal/code/scratch/bfs.svg @@ -0,0 +1 @@ +definebfsdeleteallofbfsdeleteallofqueueiflengthoflChild>0thenadd1toqueuerepeatuntillengthofqueue=0repeatuntilnotitem1ofqueue=0delete1ofqueueiflengthofqueue>0thenadditem1ofqueuetobfsadditemitem1ofqueueoflChildtoqueueadditemitem1ofqueueofmChildtoqueueadditemitem1ofqueueofrChildtoqueuedelete1ofqueue \ No newline at end of file diff --git a/contents/tree_traversal/code/scratch/dfs-from.svg b/contents/tree_traversal/code/scratch/dfs-from.svg new file mode 100644 index 000000000..c74530663 --- /dev/null +++ b/contents/tree_traversal/code/scratch/dfs-from.svg @@ -0,0 +1 @@ +definedfsfromiifi>0thenadditodfsdfsfromitemioflChilddfsfromitemiofmChilddfsfromitemiofrChild \ No newline at end of file diff --git a/contents/tree_traversal/code/scratch/dfs-in.svg b/contents/tree_traversal/code/scratch/dfs-in.svg new file mode 100644 index 000000000..058c1baa8 --- /dev/null +++ b/contents/tree_traversal/code/scratch/dfs-in.svg @@ -0,0 +1 @@ +definedfsin-orderfromiifi>0thendfsin-orderfromitemioflChildadditodfsdfspostorderfromitemiofrChild \ No newline at end of file diff --git a/contents/tree_traversal/code/scratch/dfs-post.svg b/contents/tree_traversal/code/scratch/dfs-post.svg new file mode 100644 index 000000000..4aec905f7 --- /dev/null +++ b/contents/tree_traversal/code/scratch/dfs-post.svg @@ -0,0 +1 @@ +definedfspostorderfromiifi>0thendfspostorderfromitemioflChilddfspostorderfromitemiofmChilddfspostorderfromitemiofrChildadditodfs diff --git a/contents/tree_traversal/code/scratch/dfs-stack.svg b/contents/tree_traversal/code/scratch/dfs-stack.svg new file mode 100644 index 000000000..4dc97f2c2 --- /dev/null +++ b/contents/tree_traversal/code/scratch/dfs-stack.svg @@ -0,0 +1 @@ +definedfsstackdeleteallofdfsdeleteallofstackiflengthoflChild>0thenadd1tostackrepeatuntillengthofstack=0repeatuntilnotitem1ofstack=0delete1ofstackiflengthofstack>0thenadditem1ofstacktodfsdelete1ofstackinsertitemitemlastofdfsofrChildat1ofstackinsertitemitemlastofdfsofmChildat1ofstackinsertitemitemlastofdfsoflChildat1ofstack \ No newline at end of file diff --git a/contents/tree_traversal/code/scratch/dfs.svg b/contents/tree_traversal/code/scratch/dfs.svg new file mode 100644 index 000000000..8b600a461 --- /dev/null +++ b/contents/tree_traversal/code/scratch/dfs.svg @@ -0,0 +1 @@ +definedfsdeleteallofdfsiflengthoflChild>0thendfsfrom1 \ No newline at end of file diff --git a/contents/tree_traversal/code/scratch/scratch_tree.png b/contents/tree_traversal/code/scratch/scratch_tree.png deleted file mode 100644 index a0288cfdd..000000000 Binary files a/contents/tree_traversal/code/scratch/scratch_tree.png and /dev/null differ diff --git a/contents/tree_traversal/code/scratch/struct.svg b/contents/tree_traversal/code/scratch/struct.svg new file mode 100644 index 000000000..df6561c6d --- /dev/null +++ b/contents/tree_traversal/code/scratch/struct.svg @@ -0,0 +1 @@ +deletealloflChilddeleteallofmChilddeleteallofrChildadd0tolChildadd0tomChildadd0torChild \ No newline at end of file diff --git a/contents/tree_traversal/tree_traversal.md b/contents/tree_traversal/tree_traversal.md index ebb4a4997..c33c5bb83 100644 --- a/contents/tree_traversal/tree_traversal.md +++ b/contents/tree_traversal/tree_traversal.md @@ -19,8 +19,9 @@ This has not been implemented in your chosen language, so here is the Julia code {% sample lang="py" %} [import:1-4, lang:"python"](code/python/Tree_example.py) {% sample lang="scratch" %} -This has not been implemented in your chosen language, so here is the Julia code -[import:3-7, lang:"julia"](code/julia/Tree.jl) +

+ +

{% sample lang="rs"%} [import:4-7, lang:"rust"](code/rust/tree.rs) {% sample lang="hs"%} @@ -45,8 +46,10 @@ Because of this, the most straightforward way to traverse the tree might be recu {% sample lang="py" %} [import:18-23, lang:"python"](code/python/Tree_example.py) {% sample lang="scratch" %} -This has not been implemented in your chosen language, so here is the Julia code -[import:9-16, lang:"julia"](code/julia/Tree.jl) +

+ + +

{% sample lang="rs"%} [import:9-15 lang:"rust"](code/rust/tree.rs) {% sample lang="hs"%} @@ -81,8 +84,9 @@ This has not been implemented in your chosen language, so here is the Julia code {% sample lang="py" %} [import:26-31, lang:"python"](code/python/Tree_example.py) {% sample lang="scratch" %} -This has not been implemented in your chosen language, so here is the Julia code -[import:18-26, lang:"julia"](code/julia/Tree.jl) +

+ +

{% sample lang="rs"%} This has not been implemented in your chosen language, so here is the Julia code [import:18-26, lang:"julia"](code/julia/Tree.jl) @@ -113,8 +117,9 @@ This has not been implemented in your chosen language, so here is the Julia code {% sample lang="py" %} [import:34-46, lang:"python"](code/python/Tree_example.py) {% sample lang="scratch" %} -This has not been implemented in your chosen language, so here is the Julia code -[import:28-43, lang:"julia"](code/julia/Tree.jl) +

+ +

{% sample lang="rs"%} This has not been implemented in your chosen language, so here is the Julia code [import:28-43, lang:"julia"](code/julia/Tree.jl) @@ -154,8 +159,9 @@ In code, it looks like this: {% sample lang="py" %} [import:49-60, lang:"python"](code/python/Tree_example.py) {% sample lang="scratch" %} -This has not been implemented in your chosen language, so here is the Julia code -[import:45-56, lang:"julia"](code/julia/Tree.jl) +

+ +

{% sample lang="rs"%} [import:17-24, lang:"rust"](code/rust/tree.rs) {% sample lang="hs"%} @@ -187,8 +193,9 @@ And this is exactly what Breadth-First Search (BFS) does! On top of that, it can {% sample lang="py" %} [import:63-74, lang:"python"](code/python/Tree_example.py) {% sample lang="scratch" %} -This has not been implemented in your chosen language, so here is the Julia code -[import:58-69, lang:"julia"](code/julia/Tree.jl) +

+ +

{% sample lang="rs"%} [import:26-34, lang:"rust"](code/rust/tree.rs) {% sample lang="hs"%} @@ -222,9 +229,8 @@ MainClass.java [import, lang:"python"](code/python/Tree_example.py) {% sample lang="scratch" %} -

- -

+The code snippets were taken from this [Scratch project](https://scratch.mit.edu/projects/174017753/) + {% sample lang="rs"%} [import, lang:"rust"](code/rust/tree.rs) {% sample lang="hs"%}