Git Product home page Git Product logo

binary_search_trees's Introduction

Binary Search Trees

This repository contains implementations of binary search trees (BST) in both JavaScript and Ruby.

Contents

  1. JavaScript Implementation
  2. Ruby Implementation
  3. Usage
  4. Contributing

JavaScript Implementation

The JavaScript implementation (Binary_Search_Trees.js) consists of classes for representing nodes and binary search trees.

Node Class

The Node class represents each node in the binary search tree. Each node has a data attribute to store the node's value, as well as left and right attributes to reference its left and right children.

Tree Class

The Tree class represents the binary search tree itself. It has methods for building a balanced tree from an array, inserting and deleting nodes, finding nodes, traversing the tree in various orders (level order, in-order, pre-order, post-order), calculating heights and depths, checking if the tree is balanced, and rebalancing the tree.

Ruby Implementation

The Ruby implementation (binary_search_trees.rb) also includes classes for representing nodes and binary search trees.

Node Class

Similar to the JavaScript implementation, the Node class in Ruby represents each node in the binary search tree. It has attributes for data, left, and right children.

Tree Class

The Tree class represents the binary search tree in Ruby. It provides methods for building a balanced tree from an array, inserting and deleting nodes, finding nodes, traversing the tree in various orders (level order, in-order, pre-order, post-order), calculating heights and depths, checking if the tree is balanced, and rebalancing the tree.

Usage

To use either implementation, simply include the respective JavaScript or Ruby file (Binary_Search_Trees.js or binary_search_trees.rb) in your project. You can then create instances of the Tree class and perform various operations on the binary search tree.

Contributing

Contributions to this repository are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request.

binary_search_trees's People

Contributors

ismat-samadov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.