nlptoolkit-datastructure 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,188 +1,178 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AvlTree = void 0;
4
+ const Tree_1 = require("./Tree");
5
+ const AvlTreeNode_1 = require("./AvlTreeNode");
6
+ const Stack_1 = require("../Stack");
7
+ /**
8
+ * <p>AVL (Adelson-Velskii and Landis) tree is a balanced binary search tree structure. The balance property is very simple
9
+ * and ensures the depth of the tree is in the level of O(log N).</p>
10
+ *
11
+ * <p>In AVL tree, the heights of the left and right subtrees of each node can differ by at most 1. If the heights of the
12
+ * left and right subtrees of a single node differ by more than 1, then that binary search tree is not an AVL tree.</p>
13
+ * @param T Type of the data stored in the tree node.
14
+ */
15
+ class AvlTree extends Tree_1.Tree {
16
+ constructor(comparator) {
17
+ super(comparator);
5
18
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./Tree", "./AvlTreeNode", "../Stack"], factory);
19
+ height(d) {
20
+ if (d == null) {
21
+ return 0;
22
+ }
23
+ else {
24
+ return d.height;
25
+ }
26
+ }
27
+ /**
28
+ * In rotate left, we move node k1 one level up, since due to the binary search tree
29
+ * property k2 > k1, we move node k2 one level down. The links updated are:
30
+ * <ul>
31
+ * <li>Since k2 > B > k1, the left child of node k2 is now the old right child of k1</li>
32
+ * <li>The right child of k1 is now k2 </li>
33
+ * </ul>
34
+ * Note that, the root node of the subtree is now k1. In order to modify the parent link of k2, the new root of the
35
+ * subtree is returned by the function.
36
+ * @param k2 Root of the subtree, which does not satisfy the AVL tree property.
37
+ * @return The new root of the subtree
38
+ */
39
+ rotateLeft(k2) {
40
+ let k1 = k2.left;
41
+ k2.left = k1.right;
42
+ k1.right = k2;
43
+ k2.height = Math.max(this.height(k2.left), this.height(k2.right)) + 1;
44
+ k1.height = Math.max(this.height(k1.left), k1.right.height) + 1;
45
+ return k1;
8
46
  }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AvlTree = void 0;
13
- const Tree_1 = require("./Tree");
14
- const AvlTreeNode_1 = require("./AvlTreeNode");
15
- const Stack_1 = require("../Stack");
16
47
  /**
17
- * <p>AVL (Adelson-Velskii and Landis) tree is a balanced binary search tree structure. The balance property is very simple
18
- * and ensures the depth of the tree is in the level of O(log N).</p>
48
+ * In order to restore the AVL tree property, we move node k2 one level up, since due to the binary search tree
49
+ * property k2 > k1, we move node k1 one level down. The links updated are:
50
+ * <ul>
51
+ * <li>Since k2 > B > k1, the right child of node k1 is now the old left child of k2.</li>
52
+ * <li>The left child of k2 is now k1</li>
53
+ * </ul>
54
+ * Note that, the root node of the subtree is now k2. In order to modify the parent link of k1, the new root of the
55
+ * subtree is returned by the function.
56
+ * @param k1 Root of the subtree, which does not satisfy the AVL tree property.
57
+ * @return The new root of the subtree
58
+ */
59
+ rotateRight(k1) {
60
+ let k2 = k1.right;
61
+ k1.right = k2.left;
62
+ k2.left = k1;
63
+ k2.height = Math.max(k2.left.height, this.height(k2.right)) + 1;
64
+ k1.height = Math.max(this.height(k1.left), this.height(k1.right)) + 1;
65
+ return k2;
66
+ }
67
+ /**
68
+ * <p>In the first phase we will do single right rotation on the subtree rooted with k1. With this rotation, the left
69
+ * child of node k2 will be k1, whereas the right child of node k1 will be B (the old left child of node k2).</p>
70
+ *
71
+ * <p>In the second phase, we will do single left rotation on the subtree rooted with k3. With this rotation, the
72
+ * right child of node k2 will be k3, whereas the left child of node k3 will be C (the old right child of k2).</p>
19
73
  *
20
- * <p>In AVL tree, the heights of the left and right subtrees of each node can differ by at most 1. If the heights of the
21
- * left and right subtrees of a single node differ by more than 1, then that binary search tree is not an AVL tree.</p>
22
- * @param T Type of the data stored in the tree node.
74
+ * Note that, the new root node of the subtree is now k2. In order to modify the parent link of k3, the new root of
75
+ * the subtree is returned by the function.
76
+ * @param k3 Root of the subtree, which does not satisfy the AVL tree property.
77
+ * @return The new root of the subtree
23
78
  */
24
- class AvlTree extends Tree_1.Tree {
25
- constructor(comparator) {
26
- super(comparator);
27
- }
28
- height(d) {
29
- if (d == null) {
30
- return 0;
79
+ doubleRotateLeft(k3) {
80
+ k3.left = this.rotateRight(k3.left);
81
+ return this.rotateLeft(k3);
82
+ }
83
+ /**
84
+ * <p>In the first phase we will do single right rotation on the subtree rooted with k3. With this rotation, the right
85
+ * child of node k2 will be k3, whereas the left child of node k3 will be C (the old right child of node k2).</p>
86
+ *
87
+ * <p>In the second phase, we will do single right rotation on the subtree rooted with k1. With this rotation, the left
88
+ * child of node k2 will be k1, whereas the left child of node k1 will be B (the old left child of k2).</p>
89
+ *
90
+ * Note that, the new root node of the subtree is now k2. In order to modify the parent link of k1, the new root of
91
+ * the subtree is returned by the function.
92
+ * @param k1 Root of the subtree, which does not satisfy the AVL tree property.
93
+ * @return The new root of the subtree
94
+ */
95
+ doubleRotateRight(k1) {
96
+ k1.right = this.rotateLeft(k1.right);
97
+ return this.rotateRight(k1);
98
+ }
99
+ /**
100
+ * <p>First we will proceed with the stages the same when we add a new node into a binary search tree. For this, we
101
+ * start from the root node and traverse in down manner. The current node we visit is represented with x and the
102
+ * previous node is represented with y. At each time we compare the value of the current node with the value of the
103
+ * new node. If the value of the new node is smaller than the value of the current node, the new node will be
104
+ * inserted into the left subtree of the current node. For this, we will continue with the left child to process. If
105
+ * the reverse is true, that is, if the value of the new node is larger than the value of the current node, the new
106
+ * node will be inserted into the right subtree of the current node. In this case, we will continue with the right
107
+ * child to process. At each step, we store the current node in a separate stack.</p>
108
+ *
109
+ * <p>When we insert a new node into an AVL tree, we need to change the heights of the nodes and check if the AVL tree
110
+ * property is satisfied or not. Only the height of the nodes, which we visit while we are finding the place for the
111
+ * new node, can be changed. So, what we should do is to pop those nodes from the stack one by one and change the
112
+ * heights of those nodes.</p>
113
+ *
114
+ * <p>Similarly, the nodes, which we visit while we are finding the place for the new node, may no longer satisfy the
115
+ * AVL tree property. So what we should do is to pop those nodes from the stack one by one and calculate the
116
+ * difference of the heights of their left and right subtrees. If the height difference is 2, the AVL tree property
117
+ * is not satisfied. If we added the new node into the left subtree of the left child, we need to do left single
118
+ * rotation, if we added into the right subtree of the left child, we need to do left double rotation, if we added
119
+ * into the left subtree of the right child, we need to do right double rotation, if we added into the right subtree
120
+ * of the right child, we need to the right single rotation. Since the root node of the subtree will be changed
121
+ * after a rotation, the new child of y will be the new root node t.</p>
122
+ * @param node Node to be inserted.
123
+ */
124
+ insert(node) {
125
+ let LEFT = 1, RIGHT = 2;
126
+ let y = null;
127
+ let x = this.root;
128
+ let t;
129
+ let dir1 = 0, dir2 = 0;
130
+ let c = new Stack_1.Stack();
131
+ while (x != null) {
132
+ y = x;
133
+ c.push(y);
134
+ dir1 = dir2;
135
+ if (this.comparator(node.data, x.data) < 0) {
136
+ x = x.left;
137
+ dir2 = LEFT;
31
138
  }
32
139
  else {
33
- return d.height;
140
+ x = x.right;
141
+ dir2 = RIGHT;
34
142
  }
35
143
  }
36
- /**
37
- * In rotate left, we move node k1 one level up, since due to the binary search tree
38
- * property k2 > k1, we move node k2 one level down. The links updated are:
39
- * <ul>
40
- * <li>Since k2 > B > k1, the left child of node k2 is now the old right child of k1</li>
41
- * <li>The right child of k1 is now k2 </li>
42
- * </ul>
43
- * Note that, the root node of the subtree is now k1. In order to modify the parent link of k2, the new root of the
44
- * subtree is returned by the function.
45
- * @param k2 Root of the subtree, which does not satisfy the AVL tree property.
46
- * @return The new root of the subtree
47
- */
48
- rotateLeft(k2) {
49
- let k1 = k2.left;
50
- k2.left = k1.right;
51
- k1.right = k2;
52
- k2.height = Math.max(this.height(k2.left), this.height(k2.right)) + 1;
53
- k1.height = Math.max(this.height(k1.left), k1.right.height) + 1;
54
- return k1;
55
- }
56
- /**
57
- * In order to restore the AVL tree property, we move node k2 one level up, since due to the binary search tree
58
- * property k2 > k1, we move node k1 one level down. The links updated are:
59
- * <ul>
60
- * <li>Since k2 > B > k1, the right child of node k1 is now the old left child of k2.</li>
61
- * <li>The left child of k2 is now k1</li>
62
- * </ul>
63
- * Note that, the root node of the subtree is now k2. In order to modify the parent link of k1, the new root of the
64
- * subtree is returned by the function.
65
- * @param k1 Root of the subtree, which does not satisfy the AVL tree property.
66
- * @return The new root of the subtree
67
- */
68
- rotateRight(k1) {
69
- let k2 = k1.right;
70
- k1.right = k2.left;
71
- k2.left = k1;
72
- k2.height = Math.max(k2.left.height, this.height(k2.right)) + 1;
73
- k1.height = Math.max(this.height(k1.left), this.height(k1.right)) + 1;
74
- return k2;
75
- }
76
- /**
77
- * <p>In the first phase we will do single right rotation on the subtree rooted with k1. With this rotation, the left
78
- * child of node k2 will be k1, whereas the right child of node k1 will be B (the old left child of node k2).</p>
79
- *
80
- * <p>In the second phase, we will do single left rotation on the subtree rooted with k3. With this rotation, the
81
- * right child of node k2 will be k3, whereas the left child of node k3 will be C (the old right child of k2).</p>
82
- *
83
- * Note that, the new root node of the subtree is now k2. In order to modify the parent link of k3, the new root of
84
- * the subtree is returned by the function.
85
- * @param k3 Root of the subtree, which does not satisfy the AVL tree property.
86
- * @return The new root of the subtree
87
- */
88
- doubleRotateLeft(k3) {
89
- k3.left = this.rotateRight(k3.left);
90
- return this.rotateLeft(k3);
91
- }
92
- /**
93
- * <p>In the first phase we will do single right rotation on the subtree rooted with k3. With this rotation, the right
94
- * child of node k2 will be k3, whereas the left child of node k3 will be C (the old right child of node k2).</p>
95
- *
96
- * <p>In the second phase, we will do single right rotation on the subtree rooted with k1. With this rotation, the left
97
- * child of node k2 will be k1, whereas the left child of node k1 will be B (the old left child of k2).</p>
98
- *
99
- * Note that, the new root node of the subtree is now k2. In order to modify the parent link of k1, the new root of
100
- * the subtree is returned by the function.
101
- * @param k1 Root of the subtree, which does not satisfy the AVL tree property.
102
- * @return The new root of the subtree
103
- */
104
- doubleRotateRight(k1) {
105
- k1.right = this.rotateLeft(k1.right);
106
- return this.rotateRight(k1);
107
- }
108
- /**
109
- * <p>First we will proceed with the stages the same when we add a new node into a binary search tree. For this, we
110
- * start from the root node and traverse in down manner. The current node we visit is represented with x and the
111
- * previous node is represented with y. At each time we compare the value of the current node with the value of the
112
- * new node. If the value of the new node is smaller than the value of the current node, the new node will be
113
- * inserted into the left subtree of the current node. For this, we will continue with the left child to process. If
114
- * the reverse is true, that is, if the value of the new node is larger than the value of the current node, the new
115
- * node will be inserted into the right subtree of the current node. In this case, we will continue with the right
116
- * child to process. At each step, we store the current node in a separate stack.</p>
117
- *
118
- * <p>When we insert a new node into an AVL tree, we need to change the heights of the nodes and check if the AVL tree
119
- * property is satisfied or not. Only the height of the nodes, which we visit while we are finding the place for the
120
- * new node, can be changed. So, what we should do is to pop those nodes from the stack one by one and change the
121
- * heights of those nodes.</p>
122
- *
123
- * <p>Similarly, the nodes, which we visit while we are finding the place for the new node, may no longer satisfy the
124
- * AVL tree property. So what we should do is to pop those nodes from the stack one by one and calculate the
125
- * difference of the heights of their left and right subtrees. If the height difference is 2, the AVL tree property
126
- * is not satisfied. If we added the new node into the left subtree of the left child, we need to do left single
127
- * rotation, if we added into the right subtree of the left child, we need to do left double rotation, if we added
128
- * into the left subtree of the right child, we need to do right double rotation, if we added into the right subtree
129
- * of the right child, we need to the right single rotation. Since the root node of the subtree will be changed
130
- * after a rotation, the new child of y will be the new root node t.</p>
131
- * @param node Node to be inserted.
132
- */
133
- insert(node) {
134
- let LEFT = 1, RIGHT = 2;
135
- let y = null;
136
- let x = this.root;
137
- let t;
138
- let dir1 = 0, dir2 = 0;
139
- let c = new Stack_1.Stack();
140
- while (x != null) {
141
- y = x;
142
- c.push(y);
143
- dir1 = dir2;
144
- if (this.comparator(node.data, x.data) < 0) {
145
- x = x.left;
146
- dir2 = LEFT;
147
- }
148
- else {
149
- x = x.right;
150
- dir2 = RIGHT;
151
- }
152
- }
153
- this.insertChild(y, node);
154
- while (!c.isEmpty()) {
155
- x = c.pop();
156
- if (x != null) {
157
- x.height = Math.max(this.height(x.left), this.height(x.right)) + 1;
158
- if (Math.abs(this.height(x.left) - this.height(x.right)) == 2) {
159
- if (dir1 == LEFT) {
160
- if (dir2 == LEFT) {
161
- t = this.rotateLeft(x);
162
- }
163
- else {
164
- t = this.doubleRotateLeft(x);
165
- }
144
+ this.insertChild(y, node);
145
+ while (!c.isEmpty()) {
146
+ x = c.pop();
147
+ if (x != null) {
148
+ x.height = Math.max(this.height(x.left), this.height(x.right)) + 1;
149
+ if (Math.abs(this.height(x.left) - this.height(x.right)) == 2) {
150
+ if (dir1 == LEFT) {
151
+ if (dir2 == LEFT) {
152
+ t = this.rotateLeft(x);
153
+ }
154
+ else {
155
+ t = this.doubleRotateLeft(x);
156
+ }
157
+ }
158
+ else {
159
+ if (dir2 == LEFT) {
160
+ t = this.doubleRotateRight(x);
166
161
  }
167
162
  else {
168
- if (dir2 == LEFT) {
169
- t = this.doubleRotateRight(x);
170
- }
171
- else {
172
- t = this.rotateRight(x);
173
- }
163
+ t = this.rotateRight(x);
174
164
  }
175
- y = c.pop();
176
- this.insertChild(y, t);
177
- break;
178
165
  }
166
+ y = c.pop();
167
+ this.insertChild(y, t);
168
+ break;
179
169
  }
180
170
  }
181
171
  }
182
- insertData(item) {
183
- this.insert(new AvlTreeNode_1.AvlTreeNode(item));
184
- }
185
172
  }
186
- exports.AvlTree = AvlTree;
187
- });
173
+ insertData(item) {
174
+ this.insert(new AvlTreeNode_1.AvlTreeNode(item));
175
+ }
176
+ }
177
+ exports.AvlTree = AvlTree;
188
178
  //# sourceMappingURL=AvlTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AvlTree.js","sourceRoot":"","sources":["../../source/tree/AvlTree.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,iCAA4B;IAC5B,+CAA0C;IAC1C,oCAA+B;IAE/B;;;;;;;OAOG;IACH,MAAa,OAAW,SA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CAAC;oBACL,CAAC;yBAAM,CAAC;wBACJ,IAAI,IAAI,IAAI,IAAI,EAAC,CAAC;4BACd,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAA;wBACjC,CAAC;6BAAM,CAAC;4BACJ,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;wBAC5B,CAAC;oBACL,CAAC;oBACD,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;oBACZ,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBACvB,MAAM;gBACV,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAEM,UAAU,CAAE,IAAQ;QACvB,IAAI,CAAC,MAAM,CAAC,IAAI,yBAAW,CAAI,IAAI,CAAC,CAAC,CAAA;IACzC,CAAC;CAEJ;AArKD,0BAqKC"}
@@ -1,22 +1,13 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AvlTreeNode = void 0;
4
+ const TreeNode_1 = require("./TreeNode");
5
+ class AvlTreeNode extends TreeNode_1.TreeNode {
6
+ height;
7
+ constructor(data) {
8
+ super(data);
9
+ this.height = 1;
5
10
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./TreeNode"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AvlTreeNode = void 0;
13
- const TreeNode_1 = require("./TreeNode");
14
- class AvlTreeNode extends TreeNode_1.TreeNode {
15
- constructor(data) {
16
- super(data);
17
- this.height = 1;
18
- }
19
- }
20
- exports.AvlTreeNode = AvlTreeNode;
21
- });
11
+ }
12
+ exports.AvlTreeNode = AvlTreeNode;
22
13
  //# sourceMappingURL=AvlTreeNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AvlTreeNode.js","sourceRoot":"","sources":["../../source/tree/AvlTreeNode.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,yCAAoC;IAEpC,MAAa,WAAe,SAAQ,mBAAW;QAI3C,YAAa,IAAO;YAChB,KAAK,CAAC,IAAI,CAAC,CAAA;YACX,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;QACnB,CAAC;KAEJ;IATD,kCASC"}
1
+ {"version":3,"file":"AvlTreeNode.js","sourceRoot":"","sources":["../../source/tree/AvlTreeNode.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAEpC,MAAa,WAAe,SAAQ,mBAAW;IAE3C,MAAM,CAAS;IAEf,YAAa,IAAO;QAChB,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IACnB,CAAC;CAEJ;AATD,kCASC"}
@@ -1,93 +1,85 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./BTreeNode"], factory);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BTree = void 0;
4
+ const BTreeNode_1 = require("./BTreeNode");
5
+ /**
6
+ * <p>In the computer science literature, the structures such as AVL tree, splay tree, red-black tree are proposed, which
7
+ * show the search tree property and also remain balanced after insertion and deletion operations.</p>
8
+ *
9
+ * <p>Another possibility of constructing a balanced tree structure is to store not only a single value but more than one
10
+ * value in a node. These type of tree structures are generalizations of the binary trees and called d-ary tree
11
+ * structures in the computer science literature. 2-3-4 trees, B-tree, B+ trees can be given as example d-ary tree
12
+ * structures. B+ trees, is one of the d-ary tree structures and used often in database systems.</p>
13
+ *
14
+ * <p>B+ tree is a dynamic search tree structure and consists of two parts, an index part and a data part. The index part
15
+ * is of d-ary tree structure, each node stores d {@literal <} m {@literal <} 2d values. d is a parameter of B+ tree, shows the capacity of B+
16
+ * tree and called as the degree of the tree. The root node is the single exception to this rule and can store
17
+ * 1 {@literal <} m {@literal <} 2d values. Each node also contains m + 1 links to point to its m + 1 child nodes. With the help of these
18
+ * links, the tree can be traversed in top-down manner. Let Pi represent the link pointing to the node i and Ki
19
+ * represent the i'th value in the same node, the i'th child and the ascendants of this child can take values between
20
+ * the interval Ki {@literal <} K {@literal <} Ki+1. The data are stored in the leaf nodes and due to the definition of a tree, the leaf nodes
21
+ * can not have children.</p>
22
+ * @param T Type of the data stored in the B tree node.
23
+ */
24
+ class BTree {
25
+ root = null;
26
+ comparator;
27
+ d;
28
+ /**
29
+ * Constructor of the tree. According to the comparator, the tree could contain any object.
30
+ * @param d Parameter d in d-ary tree.
31
+ * @param comparator Comparator function to compare two elements.
32
+ */
33
+ constructor(d, comparator) {
34
+ this.comparator = comparator;
35
+ this.d = d;
8
36
  }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BTree = void 0;
13
- const BTreeNode_1 = require("./BTreeNode");
14
37
  /**
15
- * <p>In the computer science literature, the structures such as AVL tree, splay tree, red-black tree are proposed, which
16
- * show the search tree property and also remain balanced after insertion and deletion operations.</p>
17
- *
18
- * <p>Another possibility of constructing a balanced tree structure is to store not only a single value but more than one
19
- * value in a node. These type of tree structures are generalizations of the binary trees and called d-ary tree
20
- * structures in the computer science literature. 2-3-4 trees, B-tree, B+ trees can be given as example d-ary tree
21
- * structures. B+ trees, is one of the d-ary tree structures and used often in database systems.</p>
22
- *
23
- * <p>B+ tree is a dynamic search tree structure and consists of two parts, an index part and a data part. The index part
24
- * is of d-ary tree structure, each node stores d {@literal <} m {@literal <} 2d values. d is a parameter of B+ tree, shows the capacity of B+
25
- * tree and called as the degree of the tree. The root node is the single exception to this rule and can store
26
- * 1 {@literal <} m {@literal <} 2d values. Each node also contains m + 1 links to point to its m + 1 child nodes. With the help of these
27
- * links, the tree can be traversed in top-down manner. Let Pi represent the link pointing to the node i and Ki
28
- * represent the i'th value in the same node, the i'th child and the ascendants of this child can take values between
29
- * the interval Ki {@literal <} K {@literal <} Ki+1. The data are stored in the leaf nodes and due to the definition of a tree, the leaf nodes
30
- * can not have children.</p>
31
- * @param T Type of the data stored in the B tree node.
38
+ * We start searching from the root node, the node with which we compare the searched value at each stage is
39
+ * represented by b, and we continue the search until we arrive the leaf nodes. In order to understand the subtree
40
+ * of node b where our searched value resides, we need to compare the searched value with the values Ki. For this,
41
+ * the function named position is given. If the searched value is larger than the last value of node b, we need to
42
+ * continue the search with the rightmost child. If the searched value is smaller than the i. value of node b, we
43
+ * need to continue the search with the i. child. As a last step, the function returns the leaf node of node b.
44
+ * @param value Value searched in B+ tree.
45
+ * @return If the value exists in the tree, the function returns the node that contains the node. Otherwise, it
46
+ * returns null.
32
47
  */
33
- class BTree {
34
- /**
35
- * Constructor of the tree. According to the comparator, the tree could contain any object.
36
- * @param d Parameter d in d-ary tree.
37
- * @param comparator Comparator function to compare two elements.
38
- */
39
- constructor(d, comparator) {
40
- this.root = null;
41
- this.comparator = comparator;
42
- this.d = d;
43
- }
44
- /**
45
- * We start searching from the root node, the node with which we compare the searched value at each stage is
46
- * represented by b, and we continue the search until we arrive the leaf nodes. In order to understand the subtree
47
- * of node b where our searched value resides, we need to compare the searched value with the values Ki. For this,
48
- * the function named position is given. If the searched value is larger than the last value of node b, we need to
49
- * continue the search with the rightmost child. If the searched value is smaller than the i. value of node b, we
50
- * need to continue the search with the i. child. As a last step, the function returns the leaf node of node b.
51
- * @param value Value searched in B+ tree.
52
- * @return If the value exists in the tree, the function returns the node that contains the node. Otherwise, it
53
- * returns null.
54
- */
55
- search(value) {
56
- let b = this.root;
57
- while (b != null && !b.leaf) {
58
- let child = b.position(value, this.comparator);
59
- if (child < b.m && b.K[child] == value) {
60
- return b;
61
- }
62
- b = b.children[child];
63
- }
64
- if (b != null) {
65
- let child = b.position(value, this.comparator);
66
- if (child < b.m && b.K[child] == value) {
67
- return b;
68
- }
48
+ search(value) {
49
+ let b = this.root;
50
+ while (b != null && !b.leaf) {
51
+ let child = b.position(value, this.comparator);
52
+ if (child < b.m && b.K[child] == value) {
53
+ return b;
69
54
  }
70
- return null;
55
+ b = b.children[child];
71
56
  }
72
- insertData(data) {
73
- if (this.root == null) {
74
- this.root = new BTreeNode_1.BTreeNode(this.d, undefined, undefined, undefined);
57
+ if (b != null) {
58
+ let child = b.position(value, this.comparator);
59
+ if (child < b.m && b.K[child] == value) {
60
+ return b;
75
61
  }
76
- if (this.root.leaf) {
77
- let s = this.root.insertLeaf(data, this.comparator);
78
- if (s != null) {
79
- let tmp = this.root;
80
- this.root = new BTreeNode_1.BTreeNode(this.d, tmp, s, tmp.K[this.d]);
81
- }
62
+ }
63
+ return null;
64
+ }
65
+ insertData(data) {
66
+ if (this.root == null) {
67
+ this.root = new BTreeNode_1.BTreeNode(this.d, undefined, undefined, undefined);
68
+ }
69
+ if (this.root.leaf) {
70
+ let s = this.root.insertLeaf(data, this.comparator);
71
+ if (s != null) {
72
+ let tmp = this.root;
73
+ this.root = new BTreeNode_1.BTreeNode(this.d, tmp, s, tmp.K[this.d]);
82
74
  }
83
- else {
84
- let s = this.root.insertNode(data, this.comparator, true);
85
- if (s != null) {
86
- this.root = s;
87
- }
75
+ }
76
+ else {
77
+ let s = this.root.insertNode(data, this.comparator, true);
78
+ if (s != null) {
79
+ this.root = s;
88
80
  }
89
81
  }
90
82
  }
91
- exports.BTree = BTree;
92
- });
83
+ }
84
+ exports.BTree = BTree;
93
85
  //# sourceMappingURL=BTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BTree.js","sourceRoot":"","sources":["../../source/tree/BTree.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,2CAAsC;IAEtC;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAa,KAAK;QAMd;;;;WAIG;QACH,YAAY,CAAS,EAAE,UAA6C;YATpE,SAAI,GAAyB,IAAI,CAAC;YAU9B,IAAI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