Lựa chọn quyền riêng tư của bạn

KiwiBee sử dụng cookie tùy chọn của Google Analytics, Google Ads và Meta Pixel để hiểu khách truy cập là người lớn, đo lường số lượt đăng ký hoàn tất và cải thiện các chiến dịch. Cookie thiết yếu luôn được bật. Pixel quảng cáo ChatGPT của OpenAI cũng đo lượt xem trang và yêu cầu đã gửi sau khi bạn đồng ý quảng cáo, và có thể dùng thông tin liên hệ đã băm để đối sánh. Chính sách quyền riêng tư

Chuyển đến nội dung chính

Binary Search Tree & AVL 3D

  • Toán học
—

Giới thiệu mô phỏng này

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.

Học sinh có thể khám phá điều gì

  • 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.

Mục tiêu học tập

  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.

Câu hỏi giáo viên thường đặt ra

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.

Nhúng mô phỏng này

Đặt vào hệ thống học tập, blog hoặc trang lớp của bạn — miễn phí.

<iframe src="https://kiwibee.io/vn/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>

Mang khoa học tương tác vào lớp học của bạn

Không gian giáo viên miễn phí của KiwiBee gộp soạn bài, phiếu bài tập, công cụ lớp học và sổ điểm vào cùng một nơi.

Bắt đầu miễn phí và tạo lớp học đầu tiên

hoặc khám phá không gian giáo viên →