你的隐私选择

KiwiBee 使用 Google Analytics、Google Ads 和 Meta Pixel 的可选 Cookie,用于了解成年访客、统计已完成的注册并改进推广活动。必要 Cookie 始终保持开启。 OpenAI 的 ChatGPT 广告像素还会在您同意广告追踪后衡量页面浏览和已提交的咨询,并可能使用经过哈希处理的联系信息进行匹配。 隐私政策

跳到主要内容

Binary Search Tree & AVL 3D

  • 数学
—

关于这个模拟实验

Binary Search Tree & AVL 3D visualizes hierarchical data structures in three-dimensional space. Every node displays its integer key and live AVL balance factor BF = height(Left) − height(Right), color-coded emerald for balanced nodes and coral red when |BF| exceeds 1. A glowing gold comparison orb hops down the tree from the root, testing whether the target key is smaller (go left) or larger (go right) than each ancestor. Students can switch between Sorted Skewed Input, Balanced Input, and Random Keys, click any node to measure exact search comparisons, and toggle Auto-balance AVL rotations to see LL, RR, LR, and RL rotations keep tree height logarithmic.

学生可以探索什么

  • Select Sorted Skewed Input and turn off Auto-balance AVL rotations to see the keys 10, 20, 30... form a degenerate diagonal chain of height 7.
  • Turn Auto-balance AVL rotations back on and watch the tree immediately fold into a balanced 3-level pyramid of height 3 with BF = 0 everywhere!
  • Click any node sphere in the 3D tree to launch the gold comparison orb from the root and count how many steps it takes to reach that key.
  • Press Insert Next Key repeatedly to watch new numbers drop into position and trigger automatic single or double AVL rotations.
  • Drag any node in 3D space to inspect its left and right subtrees, then release to watch it spring back into layout.

学习目标

  1. 1State the Binary Search Tree ordering invariant: all keys in the left subtree are smaller than the parent, and all keys in the right subtree are larger.
  2. 2Explain why inserting sorted keys into an unbalanced BST degrades search time from O(log n) to O(n).
  3. 3Compute the balance factor BF = height(L) − height(R) of any tree node and identify when an AVL rotation is required.
  4. 4Compare the worst-case number of search comparisons in a balanced AVL tree versus a skewed BST.

教师常问的问题

What makes a Binary Search Tree (BST) fast for searching?

At every node, the BST invariant tells you whether the target key must lie in the left subtree or the right subtree. In a balanced tree, each comparison eliminates half of the remaining nodes, requiring at most log₂(n) steps.

What is the worst-case scenario for a standard BST?

If keys are inserted in ascending or descending sorted order (such as 10, 20, 30, 40...), every new key attaches as a right child. The tree degenerates into a linked list of height n, slowing searches down to O(n).

How does an AVL tree prevent the tree from becoming skewed?

Named after inventors Adelson-Velsky and Landis (1962), an AVL tree tracks each node's balance factor BF = height(L) − height(R). Whenever an insertion causes |BF| to reach 2, the tree performs a local Left or Right rotation in O(1) time to restore |BF| ≤ 1.

Why does the simulation color some nodes green, cyan, and red?

Emerald green nodes have perfectly equal left and right subtree heights (BF = 0), cyan nodes differ by one level (|BF| = 1, still valid AVL), and red nodes have |BF| ≥ 2, indicating an unbalanced subtree that needs rotation.

嵌入这个模拟实验

免费嵌入你的学习平台、博客或班级网站。

<iframe src="https://kiwibee.io/zh-cn/simulations/binary-search-tree-avl-3d-3d-simulation/embed" title="Binary Search Tree &amp; AVL 3D | KiwiBee" loading="lazy" allowfullscreen style="width:100%;height:min(70vh,620px);min-height:420px;border:0;border-radius:16px"></iframe>

把互动科学带进你的课堂

KiwiBee 的免费教师工作台把备课、工作表、课堂工具和成绩册集中在一处。

免费开始,创建你的第一个班级

或了解教师工作台 →