Skip to content

Commit b52ecef

Browse files
committed
Fix data types in binary tree
1 parent d969f4d commit b52ecef

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
/**
99
* A node of the tree
1010
*
11+
* @class
1112
* @public
1213
* @constructor
13-
* @param {number|string} Value of the node
14+
* @param {Number|String} Value of the node
1415
* @param {Node} Left subling
1516
* @param {Node} Right sibling
1617
* @param {Node} Parent of the node
@@ -37,7 +38,7 @@
3738
* O(n) in the worst case.
3839
*
3940
* @public
40-
* @param {number|string} Value
41+
* @param {Number|String} Value
4142
* @param {[Node]} Current node
4243
*/
4344
BinaryTree.prototype.insert = function (value, current) {
@@ -139,7 +140,7 @@
139140
* Finds a node by it's value. Average runtime complexity O(log n)
140141
*
141142
* @public
142-
* @param {number|string} Value of the node which should be found
143+
* @param {Number|String} Value of the node which should be found
143144
*/
144145
BinaryTree.prototype.find = function (value) {
145146
return this._find(value, this._root);
@@ -149,22 +150,22 @@
149150
* Finds a node by it's value in given sub-tree. Average runtime complexity: O(log n).
150151
*
151152
* @private
152-
* @param {number|string} Value of the node which should be found
153+
* @param {Number|String} Value of the node which should be found
153154
* @param {Node} Current node to be checked
154155
*/
155156
BinaryTree.prototype._find = function (value, current) {
156157
if (!current)
157158
return null;
158-
159+
159160
if (current.value === value)
160161
return current;
161-
162+
162163
if (current.value > value)
163164
return this._find(value, current._left);
164-
165+
165166
if (current.value < value)
166167
return this._find(value, current._right);
167-
168+
168169
};
169170

170171
/**
@@ -226,7 +227,7 @@
226227
*
227228
* @private
228229
* @param {Node} Root of the sub-tree
229-
* @param {[number|string]} Current minimum value of the sub-tree
230+
* @param {[Number|String]} Current minimum value of the sub-tree
230231
* @returns {Node} The node with minimum value in the sub-tree
231232
*/
232233
BinaryTree.prototype._findMin = function (node, current) {
@@ -243,7 +244,7 @@
243244
*
244245
* @private
245246
* @param {Node} Root of the sub-tree
246-
* @param {[number|string]} Current maximum value of the sub-tree
247+
* @param {[Number|String]} Current maximum value of the sub-tree
247248
* @returns {Node} The node with maximum value in the sub-tree
248249
*/
249250
BinaryTree.prototype._findMax = function (node, current) {

src/data-structures/heap.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* Complexity O(log n)
2626
*
2727
* @private
28-
* @param {number} index The parent
28+
* @param {Number} index The parent
2929
*/
3030
Heap.prototype._heapify = function (index) {
3131
var extr = index,
@@ -55,9 +55,9 @@
5555
* Changes the key for give index. Complexity O(log n).
5656
*
5757
* @public
58-
* @param {number} index Index which key should be changed
59-
* @param {number} value New value of the key
60-
* @returns {number} parent The new position of the element
58+
* @param {Number} index Index which key should be changed
59+
* @param {Number} value New value of the key
60+
* @returns {Number} parent The new position of the element
6161
*/
6262
Heap.prototype.changeKey = function (index, value) {
6363
this._heap[index] = value;
@@ -92,8 +92,8 @@
9292
* Adds new element to the heap. Complexity O(log n).
9393
*
9494
* @public
95-
* @param {number} value The new value which will be inserted
96-
* @returns {number} The index of the inserted value
95+
* @param {Number} value The new value which will be inserted
96+
* @returns {Number} The index of the inserted value
9797
*/
9898
Heap.prototype.add = function (value) {
9999
this._heap.push(value);
@@ -104,7 +104,7 @@
104104
* Gets the current value which is on the top of the heap. Complexity O(1).
105105
*
106106
* @public
107-
* returns {numner} The current top value.
107+
* returns {Number} The current top value.
108108
*/
109109
Heap.prototype.top = function () {
110110
return this._heap[0];
@@ -116,7 +116,7 @@
116116
* Complexity O(log n).
117117
*
118118
* @public
119-
* @returns {number} The extremum value
119+
* @returns {Number} The extremum value
120120
*/
121121
Heap.prototype.extract = function () {
122122
if (!this._heap.length) {

0 commit comments

Comments
 (0)