Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flex-algo

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flex-algo - npm Package Compare versions

Comparing version 0.1.54 to 0.1.55

1

lib/binaryTree.d.ts

@@ -14,2 +14,3 @@ export declare class BinaryNode {

levelOrder(): (number | undefined)[][];
zigzagLevelOrder(): number[][];
_depth(node: BinNode): number;

@@ -16,0 +17,0 @@ depth(): number;

@@ -78,2 +78,31 @@ "use strict";

};
BinaryTree.prototype.zigzagLevelOrder = function () {
var levels = [];
var queue = [this.root];
while (queue.length) {
var levelSize = queue.length;
var count = 0;
var level = [];
while (count < levelSize) {
var current = queue.shift();
if (levels.length % 2 === 0) {
// from left to right
level.push(current === null || current === void 0 ? void 0 : current.value);
}
else {
// from right to left
level.unshift(current === null || current === void 0 ? void 0 : current.value);
}
count += 1;
if (current === null || current === void 0 ? void 0 : current.left) {
queue.push(current.left);
}
if (current === null || current === void 0 ? void 0 : current.right) {
queue.push(current.right);
}
}
levels.push(level);
}
return levels;
};
BinaryTree.prototype._depth = function (node) {

@@ -80,0 +109,0 @@ if (node === null)

2

package.json
{
"name": "flex-algo",
"version": "0.1.54",
"version": "0.1.55",
"description": "\"SDK for commonly used data structure and algorithms\"",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc