New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

namastey-binary-tree

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

namastey-binary-tree

A comprehensive package for implementing the Binary Tree data structure with essential methods for developers.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

namastey-binary-tree

namastey-binary-tree is a JavaScript package that implements the Binary Tree data structure along with various important methods such as insertion, traversal (in-order, pre-order, post-order), finding minimum and maximum values, and searching for a value.

Features

  • insert(value): Inserts a new node into the Binary Tree.
  • inOrder(): Performs an in-order traversal of the Binary Tree and returns the result as an array.
  • preOrder(): Performs a pre-order traversal of the Binary Tree and returns the result as an array.
  • postOrder(): Performs a post-order traversal of the Binary Tree and returns the result as an array.
  • findMin(): Finds and returns the minimum value in the Binary Tree.
  • findMax(): Finds and returns the maximum value in the Binary Tree.
  • search(value): Searches for a value in the Binary Tree and returns true if found, otherwise false.

Installation

To install the package globally, use the following command:

npm install -g namastey-binary-tree

Examples

const BinaryTree = require('namastey-binary-tree');

const tree = new BinaryTree();

// Insert nodes into the tree
tree.insert(50);
tree.insert(30);
tree.insert(70);
tree.insert(20);
tree.insert(40);
tree.insert(60);
tree.insert(80);

// Perform in-order traversal
console.log('In-order Traversal:', tree.inOrder()); // Output: [20, 30, 40, 50, 60, 70, 80]

// Find minimum and maximum values
console.log('Minimum Value:', tree.findMin()); // Output: 20
console.log('Maximum Value:', tree.findMax()); // Output: 80

// Search for a value in the tree
console.log('Search for 60:', tree.search(60)); // Output: true
console.log('Search for 25:', tree.search(25)); // Output: false

Keywords

FAQs

Package last updated on 27 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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