简体   繁体   中英

Max. number of rotations while inserting a new element into n-element red black tree

What is the maximum number of rotations while inserting a new element into n -element Red Black Tree?

If I'm correct, insertion that does not violate rules of RBT requries maximum of 2 rotations (2 cases). Assuming that's it, is O(1) also a correct answer?

If that's right, confirm it and please tell me, what requires maximum of 3 rotations?

A maximum of 3 operations(or 2 rotations) are needed when implementing a Red-Black Tree correctly. For example the central BST shown in this image will need 3 operations to make it confirm to the Red Black BST's rules.

该图显示了需要进行3次操作的情况

Image taken from Robert Sedgewick's slides from this MOOC. .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM