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.
Image taken from Robert Sedgewick's slides from this MOOC..