We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7a88efe commit 0fe3887Copy full SHA for 0fe3887
src/_DataStructures_/Trees/BTree/Node.js
@@ -1,6 +1,5 @@
1
module.exports = class Node {
2
- constructor(t, isLeaf) {
3
- this.t = t;
+ constructor(isLeaf) {
4
this.isLeaf = isLeaf;
5
this.keys = [];
6
this.child = [];
src/_DataStructures_/Trees/BTree/index.js
@@ -9,7 +9,7 @@ class BTree {
9
}
10
11
splitChild(index, parent, y) {
12
- const z = new Node(this.t, y.isLeaf);
+ const z = new Node(y.isLeaf);
13
z.totalKey = this.t - 1;
14
15
for (let i = 0; i < this.t - 1; i += 1) {
@@ -53,7 +53,6 @@ class BTree {
53
54
if (node.child[i + 1].totalKey === 2 * this.t - 1) {
55
this.splitChild(i + 1, node, node.child[i + 1]);
56
-
57
if (node.keys[i + 1] < key) i += 1;
58
59
this.insertNonFull(node.child[i + 1], key);
@@ -62,11 +61,11 @@ class BTree {
62
61
63
insert(key) {
64
if (this.root === null) {
65
- this.root = new Node(this.t, true);
+ this.root = new Node(true);
66
this.root.keys.push(key);
67
this.root.totalKey = 1;
68
} else if (this.root.totalKey === 2 * this.t - 1) {
69
- const newRoot = new Node(this.t, false);
+ const newRoot = new Node(false);
70
newRoot.child[0] = this.root;
71
this.splitChild(0, newRoot, this.root);
72
let i = 0;
0 commit comments