https://github.com/anvaymayekar/avl-tree-visualizer
Interactive AVL Tree Visualizer โ Real-time GUI for insert, search, and delete operations with automatic balancing, performance metrics, and visual feedback. Pure C + Win32 API.
https://github.com/anvaymayekar/avl-tree-visualizer
algorithms avl-tree c-programming data-structures dsa gui-application self-balancing-binary-search-tree tree-visualization win32api
Last synced: about 1 month ago
JSON representation
Interactive AVL Tree Visualizer โ Real-time GUI for insert, search, and delete operations with automatic balancing, performance metrics, and visual feedback. Pure C + Win32 API.
- Host: GitHub
- URL: https://github.com/anvaymayekar/avl-tree-visualizer
- Owner: anvaymayekar
- License: mit
- Created: 2025-10-29T06:14:56.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-11-08T16:23:26.000Z (3 months ago)
- Last Synced: 2025-11-08T18:13:40.551Z (3 months ago)
- Topics: algorithms, avl-tree, c-programming, data-structures, dsa, gui-application, self-balancing-binary-search-tree, tree-visualization, win32api
- Language: C
- Homepage:
- Size: 11.1 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ฒ AVL Tree Visualizer
A high-performance **Windows GUI application** for visualizing AVL Tree operations in real-time, built with **pure C** and the **Win32 API**. Features include live tree rendering, rotation animations, balance factor display, and microsecond-precision performance metrics.
> ๐ This project was developed as part of **Data Structures and Algorithms in C** coursework at **Shah & Anchor Kutchhi Engineering College**, Mumbai by **Anvay Mayekar (SYECS1 - 26)**, under the guidance of **Professor Anita Nalawade**.
---
## ๐ธ Demo
---
## ๐ About AVL Trees
An **AVL tree** (named after inventors Adelson-Velsky and Landis) is a self-balancing binary search tree where the height difference between left and right subtrees of any nodeโcalled the **balance factor**โnever exceeds 1. This strict balancing property ensures that operations like insertion, deletion, and search maintain **O(log n)** time complexity in all cases, preventing the tree from degrading into a linked list structure that would result in O(n) operations.
When an insertion or deletion violates the AVL property, the tree automatically rebalances itself through **rotations**โeither single (LL or RR) or double (LR or RL). These rotations are local operations that restructure subtrees without affecting the overall binary search tree ordering. This visualizer demonstrates these core concepts in real-time, allowing users to observe how balance factors update and which rotation types are triggered to maintain the tree's logarithmic height guarantee.
---
## โก Complexity Analysis
### Time Complexity
| Operation | Average Case | Worst Case | Description |
|-------------|--------------|------------|-------------|
| **Search** | O(log n) | O(log n) | Balanced height guarantees logarithmic search |
| **Insert** | O(log n) | O(log n) | Includes rebalancing with at most 2 rotations |
| **Delete** | O(log n) | O(log n) | May require O(log n) rotations along path |
| **Rotation**| O(1) | O(1) | Constant-time pointer reassignment |
### Space Complexity
| Aspect | Complexity | Notes |
|---------------------|------------|-------|
| **Tree Storage** | O(n) | One node per element stored |
| **Recursion Stack** | O(log n) | Maximum depth for insert/delete operations |
| **Auxiliary Space** | O(1) | No additional data structures needed |
> ๐ก **Key Advantage:** Unlike unbalanced BSTs that can degrade to O(n) height, AVL trees maintain a strict height bound of **1.44 ร logโ(n)**, ensuring predictable performance for all operations.
---
## โจ Features
- **Real-time Visualization** โ Watch AVL trees balance themselves dynamically
- **Interactive Operations** โ Insert, Search, and Delete with visual feedback
- **Rotation Detection** โ Identifies and displays LL, RR, LR, and RL rotations
- **Performance Metrics** โ Microsecond-precision execution time tracking
- **Modern UI** โ Clean, gradient-styled interface with node highlighting
- **Balance Factor Display** โ Shows height and BF for every node
- **Smooth Rendering** โ Double-buffered graphics with anti-aliasing
---
## ๐๏ธ Project Structure
```
avl-tree-visualizer/
โโโ build/ # ๐ฉ Build output directory
โ โโโ obj/ # ๐งฑ Compiled object files (.o)
โ โโโ AVLTreeVisualizer.exe # ๐ข Windows executable
โ
โโโ include/ # ๐ Header files
โ โโโ avl_tree.h # ๐ณ AVL tree data structures & operations
โ โโโ common.h # ๐จ Constants, colors, window dimensions
โ
โโโ src/ # โ๏ธ Source implementation
โ โโโ avl_tree.c # ๐งฎ Core AVL logic (insert, delete, rotate)
โ โโโ gui.c # ๐ผ๏ธ Rendering & visualization
โ โโโ main.c # ๐ Entry point & event handling
โ
โโโ sample/ # ๐ธ Demo screenshots
โ โโโ demo.png
โ
โโโ Makefile # ๐จ Build automation
โโโ README.md # ๐ Project documentation
```
---
## ๐งฐ Technologies Used




---
## ๐ฆ Installation & Setup
### Prerequisites
- **Windows OS** (Win32 API dependency)
- **GCC Compiler** (MinGW recommended)
- **Make** (for build automation)
### ๐ง Build Instructions
```bash
# Clone the repository
git clone https://github.com/anvaymayekar/avl-tree-visualizer.git
# Navigate to project directory
cd avl-tree-visualizer
# Build the project
make
# Run the executable
./build/AVLTreeVisualizer.exe
```
### ๐งน Clean Build
```bash
make clean
```
---
## ๐ฎ Usage
1. **Insert Node** โ Enter a value and click "Insert" or press `Enter`
2. **Search Node** โ Input a value and click "Search" or press `F3`
3. **Delete Node** โ Enter a value and click "Delete" or press `Delete`
### Keyboard Shortcuts
| Key | Action |
|--------------|---------------|
| `Enter` | Insert Node |
| `F3` | Search Node |
| `Delete` | Delete Node |
---
## ๐งฎ AVL Operations
| Operation | Time Complexity | Space Complexity |
|-------------|-----------------|------------------|
| Insert | O(log n) | O(1) |
| Delete | O(log n) | O(1) |
| Search | O(log n) | O(1) |
| Rotation | O(1) | O(1) |
---
## ๐จ Visual Features
- **Node Highlighting** โ Green for found nodes, red for rotations
- **Balance Factors** โ Displayed inside each node
- **Tree Height** โ Real-time height calculation
- **Rotation Tracking** โ Shows LL/RR/LR/RL rotation types
- **Performance Stats** โ Execution time in milliseconds
---
## โ๏ธ License
This project is licensed under the [MIT License](https://opensource.org/licenses/MIT).
You are free to use, modify, and distribute this software with proper attribution.
---
## ๐จโ๐ป Author
> **Anvay Mayekar**
> ๐ B.Tech in Electronics & Computer Science โ SAKEC
>
> [](https://www.github.com/anvaymayekar)
> [](https://in.linkedin.com/in/anvaymayekar)
> [](mailto:anvaay@gmail.com)