@@ -22,13 +22,13 @@ As a note, a `node` struct is not necessary in javascript, so this is an example
2222<p >
2323 <img class =" center " src =" code/scratch/struct.svg " width =" 250 " />
2424</p >
25- {% sample lang="rs"%}
25+ {% sample lang="rs" %}
2626[ import:4-7, lang:"rust"] ( code/rust/tree.rs )
27- {% sample lang="hs"%}
27+ {% sample lang="hs" %}
2828[ import:1-4, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
29- {% sample lang="swift"%}
29+ {% sample lang="swift" %}
3030[ import:1-9, lang:"swift"] ( code/swift/tree.swift )
31- {% sample lang="php"%}
31+ {% sample lang="php" %}
3232[ import:4-37, lang:"php"] ( code/php/tree_traversal.php )
3333{% sample lang="crystal" %}
3434[ import:1-5, lang:"crystal"] ( code/crystal/tree-traversal.cr )
@@ -62,13 +62,13 @@ Because of this, the most straightforward way to traverse the tree might be recu
6262 <img class =" center " src =" code/scratch/dfs.svg " width =" 250 " />
6363 <img class =" center " src =" code/scratch/dfs-from.svg " width =" 250 " />
6464</p >
65- {% sample lang="rs"%}
65+ {% sample lang="rs" %}
6666[ import:9-15 lang:"rust"] ( code/rust/tree.rs )
67- {% sample lang="hs"%}
67+ {% sample lang="hs" %}
6868[ import:6-7, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
69- {% sample lang="swift"%}
69+ {% sample lang="swift" %}
7070[ import:24-30, lang:"swift"] ( code/swift/tree.swift )
71- {% sample lang="php"%}
71+ {% sample lang="php" %}
7272[ import:41-49, lang:"php"] ( code/php/tree_traversal.php )
7373{% sample lang="crystal" %}
7474[ import:7-10, lang:"crystal"] ( code/crystal/tree-traversal.cr )
@@ -110,13 +110,13 @@ Now, in this case the first element searched through is still the root of the tr
110110<p >
111111 <img class =" center " src =" code/scratch/dfs-post.svg " width =" 300 " />
112112</p >
113- {% sample lang="rs"%}
113+ {% sample lang="rs" %}
114114[ import:17-24, lang:"rust"] ( code/rust/tree.rs )
115- {% sample lang="hs"%}
115+ {% sample lang="hs" %}
116116[ import:9-10, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
117- {% sample lang="swift"%}
117+ {% sample lang="swift" %}
118118[ import:32-38, lang:"swift"] ( code/swift/tree.swift )
119- {% sample lang="php"%}
119+ {% sample lang="php" %}
120120[ import:51-57, lang:"php"] ( code/php/tree_traversal.php )
121121{% sample lang="crystal" %}
122122[ import:12-15, lang:"crystal"] ( code/crystal/tree-traversal.cr )
@@ -153,13 +153,13 @@ In this case, the first node visited is at the bottom of the tree and moves up t
153153<p >
154154 <img class =" center " src =" code/scratch/dfs-in.svg " width =" 300 " />
155155</p >
156- {% sample lang="rs"%}
156+ {% sample lang="rs" %}
157157[ import:25-40, lang:"rust"] ( code/rust/tree.rs )
158- {% sample lang="hs"%}
158+ {% sample lang="hs" %}
159159[ import:12-16, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
160- {% sample lang="swift"%}
160+ {% sample lang="swift" %}
161161[ import:40-53, lang:"swift"] ( code/swift/tree.swift )
162- {% sample lang="php"%}
162+ {% sample lang="php" %}
163163[ import:59-78, lang:"php"] ( code/php/tree_traversal.php )
164164{% sample lang="crystal" %}
165165[ import:17-31, lang:"crystal"] ( code/crystal/tree-traversal.cr )
@@ -206,13 +206,13 @@ In code, it looks like this:
206206<p >
207207 <img class =" center " src =" code/scratch/dfs-stack.svg " width =" 400 " />
208208</p >
209- {% sample lang="rs"%}
209+ {% sample lang="rs" %}
210210[ import:41-48, lang:"rust"] ( code/rust/tree.rs )
211- {% sample lang="hs"%}
211+ {% sample lang="hs" %}
212212[ import:18-22, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
213- {% sample lang="swift"%}
213+ {% sample lang="swift" %}
214214[ import:55-67, lang:"swift"] ( code/swift/tree.swift )
215- {% sample lang="php"%}
215+ {% sample lang="php" %}
216216[ import:80-91, lang:"php"] ( code/php/tree_traversal.php )
217217{% sample lang="crystal" %}
218218[ import:33-41, lang:"crystal"] ( code/crystal/tree-traversal.cr )
@@ -251,13 +251,13 @@ And this is exactly what Breadth-First Search (BFS) does! On top of that, it can
251251<p >
252252 <img class =" center " src =" code/scratch/bfs.svg " width =" 400 " />
253253</p >
254- {% sample lang="rs"%}
254+ {% sample lang="rs" %}
255255[ import:50-58, lang:"rust"] ( code/rust/tree.rs )
256- {% sample lang="hs"%}
256+ {% sample lang="hs" %}
257257[ import:24-28, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
258- {% sample lang="swift"%}
258+ {% sample lang="swift" %}
259259[ import:69-81, lang:"swift"] ( code/swift/tree.swift )
260- {% sample lang="php"%}
260+ {% sample lang="php" %}
261261[ import:93-104, lang:"php"] ( code/php/tree_traversal.php )
262262{% sample lang="crystal" %}
263263[ import:43-51, lang:"crystal"] ( code/crystal/tree-traversal.cr )
@@ -306,13 +306,13 @@ Here is a video describing tree traversal:
306306
307307The code snippets were taken from this [ Scratch project] ( https://scratch.mit.edu/projects/174017753/ )
308308
309- {% sample lang="rs"%}
309+ {% sample lang="rs" %}
310310[ import, lang:"rust"] ( code/rust/tree.rs )
311- {% sample lang="hs"%}
311+ {% sample lang="hs" %}
312312[ import, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
313- {% sample lang="swift"%}
313+ {% sample lang="swift" %}
314314[ import, lang:"swift"] ( code/swift/tree.swift )
315- {% sample lang="php"%}
315+ {% sample lang="php" %}
316316[ import, lang:"php"] ( code/php/tree_traversal.php )
317317{% sample lang="crystal" %}
318318[ import, lang:"crystal"] ( code/crystal/tree-traversal.cr )
0 commit comments