Binary Search Tree Search Algorithm Visualization

Loading...

Loading video...

Pro
0:00 / 0:00

Binary Tree Search Animation Specification

Animation Description and Purpose

This animation visualizes the process of searching for a value in a binary search tree (BST). The goal is to demonstrate how the search algorithm traverses the tree by comparing the target value with node values and moving left or right accordingly.

Mathematical Elements

  • Binary Search Tree Properties: For any node, all values in the left subtree are less than the node's value, and all values in the right subtree are greater.
  • Search Algorithm:
    1. Start at the root node.
    2. Compare the target value with the current node's value.
    3. If equal, the search is successful.
    4. If the target is less, move to the left child.
    5. If the target is greater, move to the right child.
    6. Repeat until the value is found or a null node is reached.

Visual Elements

  • Tree Structure: A balanced binary tree with the following structure:
          8
         / \
        4   12
       / \  / \
      2  6 10 14
    
  • Nodes:
    • Shape: Circles
    • Color: Light blue (#ADD8E6) for unvisited nodes, yellow (#FFFF00) for the current node, green (#00FF00) for the found node.
    • Size: Radius of 0.5 units.
    • Labels: Node values displayed inside the circles in black text with an opaque white background.
  • Edges:
    • Lines connecting parent nodes to their children.
    • Color: Gray (#808080)
    • Thickness: 2 pixels.
  • Highlighting:
    • Current node in the search path is highlighted with a yellow glow effect.
    • Traversed path edges are highlighted in red (#FF0000).

Animation Sequence

  1. Initial Setup (0 - 2 seconds):

    • The entire tree is drawn on the screen with all nodes in light blue.
    • The root node (8) is briefly highlighted to indicate the starting point.
  2. Search Process (2 - 15 seconds):

    • Target value to search for: 6 (displayed as text at the top of the screen with an opaque background).
    • Step 1 (2 - 4 seconds): Compare 6 with root node (8). Since 6 < 8, move to the left child (4). Highlight the edge from 8 to 4 in red.
    • Step 2 (4 - 6 seconds): Compare 6 with node (4). Since 6 > 4, move to the right child (6). Highlight the edge from 4 to 6 in red.
    • Step 3 (6 - 8 seconds): Compare 6 with node (6). Values are equal, indicating a successful search. Node (6) turns green.
  3. Conclusion (15 - 20 seconds):

    • All nodes return to their original light blue color except for the found node (6), which remains green.
    • The traversed path edges (8 → 4 → 6) remain highlighted in red.
    • A checkmark symbol appears next to the target value to indicate a successful search.

Timing and Transitions

  • Each comparison and movement step takes approximately 2 seconds.
  • Smooth transitions between highlighting nodes and edges using linear interpolation.
  • A slight pause (0.5 seconds) at each node during comparison to allow the viewer to process the step.

Camera Angles and Perspectives

  • Static camera angle centered on the tree.
  • The tree is displayed in a hierarchical layout with the root at the top and children below their parents.
  • Zoom level adjusted to fit the entire tree within the frame with some padding.

Additional Details

  • The animation duration is 20 seconds, which is within the recommended limit.
  • Text labels for node values are essential for understanding the search process and are displayed with an opaque background to ensure readability.
  • The animation focuses on visualizing the search algorithm without any additional distractions.

Created By

Tiga LiangTiga Liang

Description

This animation demonstrates how a binary search tree is traversed to find a target value. It highlights the step-by-step comparison process, showing node and edge highlighting as the algorithm moves from the root to the target node.

Created At

Jan 15, 2026, 03:24 PM

Tags

binary-search-treesearch-algorithmtree-traversal

Status

Completed
AI Model
DevStral 2512

Fork