Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 758cb42

Browse files
tree traversal
1 parent f40834f commit 758cb42

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

‎book/book.adoc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ include::chapters/non-linear-data-structures-intro.adoc[]
7676
// (g)
7777
include::chapters/tree.adoc[]
7878

79-
include::chapters/tree--binary-tree-traversal.adoc[]
8079

8180
// (g)
8281
include::chapters/tree--binary-search-tree.adoc[]
8382

83+
include::chapters/tree--binary-tree-traversal.adoc[]
84+
8485
include::chapters/tree--self-balancing-rotations.adoc[]
8586

8687
:leveloffset: +1

‎src/data-structures/trees/binary-search-tree.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ class BinarySearchTree {
201201
}
202202
}
203203

204+
// tag::inOrderTraversal[]
204205
/**
205206
* In-order traversal on a tree: left-root-right.
206207
*
@@ -213,7 +214,9 @@ class BinarySearchTree {
213214
yield node;
214215
if (node && node.right) { yield* this.inOrderTraversal(node.right); }
215216
}
217+
// end::inOrderTraversal[]
216218

219+
// tag::preOrderTraversal[]
217220
/**
218221
* Pre-order traversal on a tree: root-left-right.
219222
* Similar results to DFS
@@ -226,7 +229,9 @@ class BinarySearchTree {
226229
if (node.left) { yield* this.preOrderTraversal(node.left); }
227230
if (node.right) { yield* this.preOrderTraversal(node.right); }
228231
}
232+
// end::preOrderTraversal[]
229233

234+
// tag::postOrderTraversal[]
230235
/**
231236
* Post-order traversal on a tree: left-right-root.
232237
*
@@ -237,6 +242,7 @@ class BinarySearchTree {
237242
if (node.right) { yield* this.postOrderTraversal(node.right); }
238243
yield node;
239244
}
245+
// end::postOrderTraversal[]
240246

241247
/**
242248
* Represent Binary Tree as an array.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /