Skip to content

Commit 0fe3887

Browse files
committed
--update : remove t property from node
1 parent 7a88efe commit 0fe3887

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/_DataStructures_/Trees/BTree/Node.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module.exports = class Node {
2-
constructor(t, isLeaf) {
3-
this.t = t;
2+
constructor(isLeaf) {
43
this.isLeaf = isLeaf;
54
this.keys = [];
65
this.child = [];

src/_DataStructures_/Trees/BTree/index.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class BTree {
99
}
1010

1111
splitChild(index, parent, y) {
12-
const z = new Node(this.t, y.isLeaf);
12+
const z = new Node(y.isLeaf);
1313
z.totalKey = this.t - 1;
1414

1515
for (let i = 0; i < this.t - 1; i += 1) {
@@ -53,7 +53,6 @@ class BTree {
5353

5454
if (node.child[i + 1].totalKey === 2 * this.t - 1) {
5555
this.splitChild(i + 1, node, node.child[i + 1]);
56-
5756
if (node.keys[i + 1] < key) i += 1;
5857
}
5958
this.insertNonFull(node.child[i + 1], key);
@@ -62,11 +61,11 @@ class BTree {
6261

6362
insert(key) {
6463
if (this.root === null) {
65-
this.root = new Node(this.t, true);
64+
this.root = new Node(true);
6665
this.root.keys.push(key);
6766
this.root.totalKey = 1;
6867
} else if (this.root.totalKey === 2 * this.t - 1) {
69-
const newRoot = new Node(this.t, false);
68+
const newRoot = new Node(false);
7069
newRoot.child[0] = this.root;
7170
this.splitChild(0, newRoot, this.root);
7271
let i = 0;

0 commit comments

Comments
 (0)