We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eb8c307 commit cc3c4c7Copy full SHA for cc3c4c7
2 files changed
JavaScript/5-bst.js
@@ -11,10 +11,10 @@ tree.insert = (root, data) => {
11
if (data < root[0]) {
12
if (root[1] === null) root[1] = tree(data);
13
else tree.insert(root[1], data);
14
- } else {
15
- if (root[2] === null) root[2] = tree(data);
16
- else tree.insert(root[2], data);
+ return;
17
}
+ if (root[2] === null) root[2] = tree(data);
+ else tree.insert(root[2], data);
18
};
19
20
tree.search = (root, data) => {
JavaScript/8-bst-del.js
@@ -52,7 +52,9 @@ tree.insert(root, 2);
52
tree.insert(root, 3);
53
tree.insert(root, 1);
54
55
-tree.search(root, 2, node => console.log(node));
+tree.search(root, 2, node => {
56
+ console.log(node);
57
+});
58
59
const node = tree.search(root, 2);
60
console.dir(node, { depth: 3 });
0 commit comments