https://github.com/haminimi/binary-search-tree
A balanced binary search tree with all the basic methods.
https://github.com/haminimi/binary-search-tree
algorithms-and-data-structures algorithms-datastructures balanced-binary-search-trees balanced-search-trees balanced-tree binary-search-tree binarysearchtree data-structures datastructures javascript theodinproject webdevelopment
Last synced: 4 months ago
JSON representation
A balanced binary search tree with all the basic methods.
- Host: GitHub
- URL: https://github.com/haminimi/binary-search-tree
- Owner: Haminimi
- Created: 2023-12-23T23:10:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-28T10:54:11.000Z (about 1 year ago)
- Last Synced: 2025-01-13T17:51:39.486Z (6 months ago)
- Topics: algorithms-and-data-structures, algorithms-datastructures, balanced-binary-search-trees, balanced-search-trees, balanced-tree, binary-search-tree, binarysearchtree, data-structures, datastructures, javascript, theodinproject, webdevelopment
- Language: JavaScript
- Homepage: https://haminimi.github.io/binary-search-tree/
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Balanced Binary Search Tree
## Description
A balanced binary search tree with all the basic methods. [The project](https://www.theodinproject.com/lessons/javascript-binary-search-trees) is a part of [The Odin Project](https://www.theodinproject.com/dashboard)'s curriculum. The Odin Project provides a high quality web development education maintained by an open source community.
## Live Preview
Open up your [developer console](https://haminimi.github.io/binary-search-tree/) to see some of the [binary search tree](https://haminimi.github.io/binary-search-tree/) methods in action.
## Methods
- **insert:** accepts a value to insert
- **delete:** accepts a value to delete
- **find:** accepts a value and returns the node with the given value
- **levelOrder:** accepts a random optional callback function as its parameter, traverses the tree in breadth-first level order and provide each node as an argument to the callback, if no callback is given as an argument it returns an array of values
- **inOrder, preOrder, and postOrder:** functions that also accept a random optional callback as a parameter, they traverse the tree in their respective depth-first order and yield each node to the provided callback, if no callback is given as an argument, they return an array of values
- **height:** accepts a node and returns its height
- **depth:** accepts a node and returns its depth
- **isBalanced:** checks if the tree is balanced
- **rebalance:** rebalances an unbalanced tree
- **prettyPrint:** console.log the tree in a structured format**To Do:**
- [ ] **Try to improve and optimize the methods**
## Tech
**The project is built with:**
- HTML
- Vanilla JavaScript**Tools**
- Visual Studio Code
- Git
## Covered Topics
**This section mentions the main topics covered during project work and prior lessons**
- Algorithms and Data Structures
- Time and Space Complexity
- Binary Search Algorithm
- Breadth First Search and Depth First Search
- Linked List
- Balanced Binary Search Tree
## Reflection
The levelOrder and height methods are implemented using both the iterative and recursive approaches. For other methods, I have chosen what is in my opinion the better approach for each particular method.I love to see a tree printed in the console. 😄
## Credits
- Icon used for the favicon image is one of the [Hierarchy icons created by Freepik - Flaticon](https://www.flaticon.com/free-icons/hierarchy).
## Happy coding!