@@ -22,13 +22,13 @@ As a note, a `node` struct is not necessary in javascript, so this is an example
22
22
<p >
23
23
<img class =" center " src =" code/scratch/struct.svg " width =" 250 " />
24
24
</p >
25
- {% sample lang="rs"%}
25
+ {% sample lang="rs" %}
26
26
[ import:4-7, lang:"rust"] ( code/rust/tree.rs )
27
- {% sample lang="hs"%}
27
+ {% sample lang="hs" %}
28
28
[ import:1-4, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
29
- {% sample lang="swift"%}
29
+ {% sample lang="swift" %}
30
30
[ import:1-9, lang:"swift"] ( code/swift/tree.swift )
31
- {% sample lang="php"%}
31
+ {% sample lang="php" %}
32
32
[ import:4-37, lang:"php"] ( code/php/tree_traversal.php )
33
33
{% sample lang="crystal" %}
34
34
[ 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
62
62
<img class =" center " src =" code/scratch/dfs.svg " width =" 250 " />
63
63
<img class =" center " src =" code/scratch/dfs-from.svg " width =" 250 " />
64
64
</p >
65
- {% sample lang="rs"%}
65
+ {% sample lang="rs" %}
66
66
[ import:9-15 lang:"rust"] ( code/rust/tree.rs )
67
- {% sample lang="hs"%}
67
+ {% sample lang="hs" %}
68
68
[ import:6-7, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
69
- {% sample lang="swift"%}
69
+ {% sample lang="swift" %}
70
70
[ import:24-30, lang:"swift"] ( code/swift/tree.swift )
71
- {% sample lang="php"%}
71
+ {% sample lang="php" %}
72
72
[ import:41-49, lang:"php"] ( code/php/tree_traversal.php )
73
73
{% sample lang="crystal" %}
74
74
[ 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
110
110
<p >
111
111
<img class =" center " src =" code/scratch/dfs-post.svg " width =" 300 " />
112
112
</p >
113
- {% sample lang="rs"%}
113
+ {% sample lang="rs" %}
114
114
[ import:17-24, lang:"rust"] ( code/rust/tree.rs )
115
- {% sample lang="hs"%}
115
+ {% sample lang="hs" %}
116
116
[ import:9-10, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
117
- {% sample lang="swift"%}
117
+ {% sample lang="swift" %}
118
118
[ import:32-38, lang:"swift"] ( code/swift/tree.swift )
119
- {% sample lang="php"%}
119
+ {% sample lang="php" %}
120
120
[ import:51-57, lang:"php"] ( code/php/tree_traversal.php )
121
121
{% sample lang="crystal" %}
122
122
[ 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
153
153
<p >
154
154
<img class =" center " src =" code/scratch/dfs-in.svg " width =" 300 " />
155
155
</p >
156
- {% sample lang="rs"%}
156
+ {% sample lang="rs" %}
157
157
[ import:25-40, lang:"rust"] ( code/rust/tree.rs )
158
- {% sample lang="hs"%}
158
+ {% sample lang="hs" %}
159
159
[ import:12-16, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
160
- {% sample lang="swift"%}
160
+ {% sample lang="swift" %}
161
161
[ import:40-53, lang:"swift"] ( code/swift/tree.swift )
162
- {% sample lang="php"%}
162
+ {% sample lang="php" %}
163
163
[ import:59-78, lang:"php"] ( code/php/tree_traversal.php )
164
164
{% sample lang="crystal" %}
165
165
[ import:17-31, lang:"crystal"] ( code/crystal/tree-traversal.cr )
@@ -206,13 +206,13 @@ In code, it looks like this:
206
206
<p >
207
207
<img class =" center " src =" code/scratch/dfs-stack.svg " width =" 400 " />
208
208
</p >
209
- {% sample lang="rs"%}
209
+ {% sample lang="rs" %}
210
210
[ import:41-48, lang:"rust"] ( code/rust/tree.rs )
211
- {% sample lang="hs"%}
211
+ {% sample lang="hs" %}
212
212
[ import:18-22, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
213
- {% sample lang="swift"%}
213
+ {% sample lang="swift" %}
214
214
[ import:55-67, lang:"swift"] ( code/swift/tree.swift )
215
- {% sample lang="php"%}
215
+ {% sample lang="php" %}
216
216
[ import:80-91, lang:"php"] ( code/php/tree_traversal.php )
217
217
{% sample lang="crystal" %}
218
218
[ 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
251
251
<p >
252
252
<img class =" center " src =" code/scratch/bfs.svg " width =" 400 " />
253
253
</p >
254
- {% sample lang="rs"%}
254
+ {% sample lang="rs" %}
255
255
[ import:50-58, lang:"rust"] ( code/rust/tree.rs )
256
- {% sample lang="hs"%}
256
+ {% sample lang="hs" %}
257
257
[ import:24-28, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
258
- {% sample lang="swift"%}
258
+ {% sample lang="swift" %}
259
259
[ import:69-81, lang:"swift"] ( code/swift/tree.swift )
260
- {% sample lang="php"%}
260
+ {% sample lang="php" %}
261
261
[ import:93-104, lang:"php"] ( code/php/tree_traversal.php )
262
262
{% sample lang="crystal" %}
263
263
[ import:43-51, lang:"crystal"] ( code/crystal/tree-traversal.cr )
@@ -306,13 +306,13 @@ Here is a video describing tree traversal:
306
306
307
307
The code snippets were taken from this [ Scratch project] ( https://scratch.mit.edu/projects/174017753/ )
308
308
309
- {% sample lang="rs"%}
309
+ {% sample lang="rs" %}
310
310
[ import, lang:"rust"] ( code/rust/tree.rs )
311
- {% sample lang="hs"%}
311
+ {% sample lang="hs" %}
312
312
[ import, lang:"haskell"] ( code/haskell/TreeTraversal.hs )
313
- {% sample lang="swift"%}
313
+ {% sample lang="swift" %}
314
314
[ import, lang:"swift"] ( code/swift/tree.swift )
315
- {% sample lang="php"%}
315
+ {% sample lang="php" %}
316
316
[ import, lang:"php"] ( code/php/tree_traversal.php )
317
317
{% sample lang="crystal" %}
318
318
[ import, lang:"crystal"] ( code/crystal/tree-traversal.cr )
0 commit comments