This project is part of my Data Structures and Algorithms practice from The Odin Project. It focuses on building a Balanced Binary Search Tree from scratch in JavaScript, to better understand how data structures work under the hood.
- Implemented a Balanced Binary Search Tree from scratch
- Learned how to use a Queue to perform level-order traversal
- Deepened my understanding of JavaScript Classes and recursion
- Practiced time complexity analysis for various tree operations
- Strengthened my understanding of references and immutability in data structures
Represent each node in the tree Properties:
value: the stored dataleft: pointer to the left childright: pointer to the right child
Used to manage nodes during level-order traversal.
enqueue(node)dequeue()queueLength()isEmpty()
The main structure that stores nodes and provides operations to interact with them.
prettyPrint()→ visualize the tree in the consolebuildTree(array)→ create a balanced BST from an arrayinsert(value)→ insert a new nodedeleteItem(value)→ remove a nodefind(value)→ search for a node with the valuelevelOrderForEach(callback)→ breadth-first traversalpreOrderForEach(callback)→ depth-first (root → left → right)inOrderForEach(callback)→ depth-first (left → root → right)postOrderForEach(callback)→ depth-first (left → right → root)height(value)→ find the height of the node with the valuedepth(value)→ find how deep a node is from the rootisBalanced()→ check if the tree is balancedrebalance()→ balance an unbalanced tree
- ✅ Build a balanced tree automatically from an array
- ✅ Handle insertions and deletions while preserving BST rules
- ✅ Traverse the tree in multiple orders
- ✅ Rebalance the tree
- ✅ Includes a prettyPrint() helper to visualize the structure
- Recursion and base cases
- Reference vs value in JavaScript
- Queue-based traversal algorithms
- Balanced tree construction
- Divide and conquer logic
Marcos Curbeco
The Odin Project Student | Web Developer in Progress