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

namastey-b-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-b-tree

A JavaScript package for implementing the B-Tree data structure, providing efficient data storage and retrieval.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
0
Weekly downloads
 
Created
Source

namastey-b-tree

A JavaScript package implementing the B-Tree data structure.

Description

namastey-b-tree is a simple and efficient implementation of the B-Tree data structure, supporting various key operations. B-Trees are self-balancing trees that maintain sorted data and allow searches, sequential access, insertions, and deletions in logarithmic time.

Features

  • traverse(): Traverse the B-Tree and print all keys in sorted order.
  • search(key): Search for a key in the B-Tree. Returns the node containing the key or null if not found.
  • insert(key): Insert a new key into the B-Tree. Handles splitting nodes if necessary.

Installation

To install the package globally, use the following command:

npm install -g namastey-b-tree

Examples

const BTree = require('namastey-b-tree');

const tree = new BTree(3); // Creating a B-Tree with a minimum degree of 3
tree.insert(10);
tree.insert(20);
tree.insert(5);
tree.insert(6);
tree.insert(12);
tree.insert(30);
tree.insert(7);
tree.insert(17);

console.log('Traversal of the constructed B-Tree:');
tree.traverse(); 
// Output: 5 6 7 10 12 17 20 30

console.log('Search result for key 6:', tree.search(6)); 
// Output: Node containing key 6

console.log('Search result for key 15:', tree.search(15)); 
// Output: null

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