返回卡包市场

Red-black BST'

暂无描述。系统推荐的高质量记忆内容,适合每天坚持背诵学习。

卡片总数: 9内容版本: v4公开卡包更新时间: 8/1/2026

卡片预览 (9 张)

#1
正面 (问题)

What is a RB tree?

背面 (解答)

Encoding of BST by adding extra information to create 3-nodes.

#2
正面 (问题)

What are the red and black links and what are their properties?

背面 (解答)

• Red links bind two 2-nodes to represent 3-nodes • Black links bind together 2-3 trees Red links lean left and no node can have two connected. The tree has perfect black balance.

#3
正面 (问题)

What is left and right rotation?

背面 (解答)

Used to correct right-leaning links or links in a row. * If right leaning, use left rotation to return link to a node that is the root of a RD BST for the same set of keys whose left link is red (Switching from smaller at root to larger at root. Becomes left child of right child.) * Right rotation: Becomes right child of left child

#4
正面 (问题)

How do we insert into a single 2-node?

背面 (解答)

Insert into key and perform rotation if necessary.

#5
正面 (问题)

How do we insert into a 2-node at the bottom?

背面 (解答)

• If parent is 2-node, do the same as with 2-node insertion • Parent will become a 3-node.

#6
正面 (问题)

What are the 3 cases for insertion into a 3-node?

背面 (解答)

If inserting key is larger: * Atttach to right * Make balance with middle key at root * Flip colours from red to black If key smaller: * Goes on left * Reduce to previous case by rotating top link to the right If key between: * Right leaning below a left leaning * Reduce to previous by rotating right link to left

#7
正面 (问题)

How do we insert a 3-node at the bottom of the tree?

背面 (解答)

Same cases arise as above.

#8
正面 (问题)

What is the height of a red black BST?

背面 (解答)

No more than 2lg N

#9
正面 (问题)

背面 (解答)