https://github.com/everthis/bst-visualizer
BTree visualizer
https://github.com/everthis/bst-visualizer
Last synced: 5 days ago
JSON representation
BTree visualizer
- Host: GitHub
- URL: https://github.com/everthis/bst-visualizer
- Owner: everthis
- License: apache-2.0
- Created: 2020-06-03T05:48:27.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-09T12:53:41.000Z (almost 6 years ago)
- Last Synced: 2026-05-27T13:39:04.698Z (5 days ago)
- Language: JavaScript
- Homepage:
- Size: 157 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BST-visualizer
```js
class Node {
constructor(val) {
this.val = val
this.left = null
this.right = null
}
}
const root = new Node([32])
const l1_1 = new Node([19])
const l1_2 = new Node([14])
const l2_0 = new Node([9])
const l2_1 = new Node([8])
const l2_2 = new Node([5])
const l2_3 = new Node([33])
const l3_1 = new Node([1,2,3])
const l3_2 = new Node([1])
const l4_2 = new Node([10, 11, 12])
const l5_2 = new Node([11])
const l6_2 = new Node([12])
const l7_2 = new Node([13])
const l8_2 = new Node([14,15])
const l4_1 = new Node([99])
const l4_3 = new Node([79])
const l5_3 = new Node([78,79,80])
root.left = l1_1
root.right = l1_2
l1_2.right = l2_0
l1_2.left = l2_3
l1_1.left = l2_1
l1_1.right = l2_2
l2_2.right = l3_2
l3_2.right = l4_2
l4_2.right = l5_2
l5_2.right = l6_2
l6_2.right = l7_2
l7_2.right = l8_2
l2_1.left = l3_1
l3_1.left = l4_1
l2_3.left = l4_3
l4_3.left = l5_3
const cvs = document.getElementById("cvs")
const tree = new BinaryTree({ canvas: cvs, root })
tree.plot()
```
