Comparing version 0.1.4 to 0.1.5
@@ -7,7 +7,11 @@ export declare class BinaryNode { | ||
} | ||
type BinNode = BinaryNode | null | undefined; | ||
export declare class BinaryTree { | ||
root: BinaryNode | null; | ||
root: BinNode; | ||
constructor(); | ||
insert(data: (number | null)[]): BinaryNode | null | undefined; | ||
insert(data: (number | null)[]): BinNode; | ||
levelOrder(): (number | undefined)[][]; | ||
_depth(node: BinaryNode | null | undefined): number; | ||
depth(): number; | ||
} | ||
export {}; |
@@ -78,4 +78,22 @@ "use strict"; | ||
}; | ||
BinaryTree.prototype._depth = function (node) { | ||
if (node == null) | ||
return 0; | ||
if ((node === null || node === void 0 ? void 0 : node.left) === null && node.right === null) | ||
return 1; | ||
var leftDepth = 0; | ||
var rightDepth = 0; | ||
if (node.left !== null) { | ||
leftDepth = this._depth(node.left) + 1; | ||
} | ||
if (node.right !== null) { | ||
rightDepth = this._depth(node.right) + 1; | ||
} | ||
return leftDepth > rightDepth ? leftDepth : rightDepth; | ||
}; | ||
BinaryTree.prototype.depth = function () { | ||
return this._depth(this.root); | ||
}; | ||
return BinaryTree; | ||
}()); | ||
exports.BinaryTree = BinaryTree; |
{ | ||
"name": "flex-algo", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "\"SDK for commonly used data structure and algorithms\"", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9304
219