Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/subrat611/leetcode-tree-visualizer

It enables you to view the tree that corresponds to the array of test cases.
https://github.com/subrat611/leetcode-tree-visualizer

binary-tree-visualization data-structures javascript typescript vitejs

Last synced: 3 days ago
JSON representation

It enables you to view the tree that corresponds to the array of test cases.

Awesome Lists containing this project

README

        

## Leetcode Tree Visualizer

Don't just run your test cases through your mind, visualize them instead! 😉

### Decoding characteristics of tree

- Drawing 2D tree graphics using HTML `canvas`.

### Representing/rendering node logic

- A node in canvas represents these properties `width`, `height`, `point (x,y)`, `radius`, and the node `value`.

![image](https://github.com/subrat611/leetcode-tree-visualizer/assets/77252075/555648b9-17e1-47d1-ae83-6666001b7eb3)

### Understanding canvas height and width for tree

- Height of the canvas

![canvas-height](https://github.com/subrat611/leetcode-tree-visualizer/assets/77252075/701338b6-3f4e-4942-97ec-2cdc8e2041e0)

- Widht of the canvas

![canvas-width](https://github.com/subrat611/leetcode-tree-visualizer/assets/77252075/50f839c2-ce94-4913-b7be-b8831358d9f7)

### Calculate the coordinates for placing the tree on the screen

![coordinates](https://github.com/subrat611/leetcode-tree-visualizer/assets/77252075/b8185588-79f5-4c16-a1cb-8bf7904e397d)

### Draw tree recursively

#### Algorithm

- Find the root node coordinates from `xStart` to `xEnd`.
- Draw the root node on the coordinates found at `step 1`.
- Recursively draw left & right nodes.
- Connect edges of each nodes.

### 🔨 Technologies

- `Vitejs` + `TypeScript`
- `Tailwind css`