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

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.

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


AVL Tree Visualizer 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

![C](https://img.shields.io/badge/C_Language-00599C?style=for-the-badge&logo=c&logoColor=white)
![Win32 API](https://img.shields.io/badge/Win32_API-0078D6?style=for-the-badge&logo=windows&logoColor=white)
![GDI+](https://img.shields.io/badge/GDI+-Graphics-blue?style=for-the-badge)
![GCC](https://img.shields.io/badge/GCC-Compiler-A8B9CC?style=for-the-badge&logo=gnu&logoColor=white)

---

## ๐Ÿ“ฆ 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
>
> [![GitHub](https://img.shields.io/badge/GitHub-181717.svg?style=for-the-badge&logo=GitHub&logoColor=white)](https://www.github.com/anvaymayekar)
> [![LinkedIn](https://img.shields.io/badge/LinkedIn-0A66C2.svg?style=for-the-badge&logo=LinkedIn&logoColor=white)](https://in.linkedin.com/in/anvaymayekar)
> [![Gmail](https://img.shields.io/badge/Gmail-D14836.svg?style=for-the-badge&logo=gmail&logoColor=white)](mailto:anvaay@gmail.com)