Giter Site home page Giter Site logo

binary-search-tree's Introduction

Balanced Search Tree

A brief description of what this project does

A balanced search tree is a type of tree data structure that is designed to maintain a balance between the left and right subtrees of every node in the tree. This balance helps to ensure that the tree remains relatively efficient, even as it grows larger and larger. In a balanced search tree, the height of the left and right subtrees of every node may differ by no more than one, and the tree is restructured as needed to maintain this balance.

Functions

  • Node(value) node constructor

Tree(array) will remove duplicates from the array and create balanced search tree;

Insert(value) insert value on the leaf node;

Delete(value) remove node with given value from the tree;

find(value) accepts a value and returns the node with the given value;

levelOrder accepts another function as a parameter. It will traverse the tree in breadth-first level order and provide each node as the argument to the provided function.

inorder, preorder, postorder functions that accept a function parameter. Each of these functions should traverse the tree in their respective depth-first order and yield each node to the provided function given as an argument. The functions should return an array of values if no function is given.

height() accepts a node and returns its height. Height is defined as the number of edges in longest path from a given node to a leaf node.

depth() function which accepts a node and returns its depth. Depth is defined as the number of edges in path from a given node to the tree’s root node.

isBalanced function which checks if the tree is balanced. A balanced tree is one where the difference between heights of left subtree and right subtree of every node is not more than 1.

rebalance function which rebalances an unbalanced tree.

πŸ”— Links

twitter

binary-search-tree's People

Contributors

cjskii 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.