Skip to content

[Feature]: Add AVL Tree (Self-Balancing BST) visualizer to Abstract Data Types #801

Description

@ruhelamahi7-code

Problem or limitation

The existing Binary Tree visualizer shows a basic tree but does not demonstrate self-balancing. Students learning AVL Trees frequently struggle to understand:

  • How the balance factor is calculated at each node
  • When and why rotations are triggered (LL, RR, LR, RL)
  • How the tree restructures itself after every insert or delete

A visual, interactive AVL Tree would make these concepts immediately clear.

Proposed solution

Add a new AVL Tree tab to the Abstract Data Types page following the same pattern as the existing Trie, Hash Table and Segment Tree visualizers, with:

Operations

  • Insert — insert a value, show rotations triggered and updated balance factors
  • Delete — delete a value and show rebalancing
  • Search — highlight the search path from root to target node

Visual Features

  • Display each node with its value and balance factor (-1, 0, +1)
  • Color-code nodes by balance factor: green (balanced), yellow (±1), red (unbalanced before rotation)
  • Animate rotations — LL, RR, LR, RL — with labels showing which rotation was applied
  • Show the tree height in the stats panel
  • Sample data button to pre-load example values

Alternatives considered

  • Deque (Double-Ended Queue) — simpler and similar to the existing Queue visualizer, lower educational value compared to AVL Tree
  • Red-Black Tree — also a self-balancing BST but more complex with 5 cases; AVL Tree is more commonly taught first and easier to visualize
  • B-Tree — important for databases but complex; AVL Tree fills a more immediate gap for DSA learners
  • Splay Tree — niche and rarely taught at introductory/intermediate level

Use case

  • Students learning self-balancing BSTs can visually see how balance factors change after each insertion and which rotation is triggered
  • Interview preparation — AVL Trees and rotations appear frequently in FAANG-level technical interviews on tree balancing
  • Understanding why O(log n) is guaranteed — seeing the tree stay balanced after every operation makes this intuitive
  • Comparing with the existing unbalanced Binary Tree tab helps students understand the cost of not balancing
  • Language comparison — seeing AVL Tree implemented across 7 languages helps developers understand language-specific nuances

Additional context

AVL Trees are covered in every advanced DSA course (MIT 6.006, CLRS textbook Chapter 13) and are the foundational self-balancing BST that students learn before Red-Black Trees. The existing Binary Tree visualizer on AlgoScope does not show balancing behavior, leaving a significant gap for advanced learners.

The implementation will follow the exact same component pattern established by the existing visualizers (Trie PR #789, Hash Table PR #795, Segment Tree) — a self-contained AVLTreeIV.jsx file with matching Tailwind CSS dark theme styling. Reference code will be added to adtSources.js in all 7 languages already supported by the platform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GSSoCOfficial issue for GSSoC contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions