| 1. |
List The Types Of Rotations Available In Splay Tree? |
|
Answer» <P>Let us assume that the splay is performed at vertex v, whose parent and grandparent are p and g respectively. Then, the three ROTATIONS are named as: Zig: If p is the root and v is the left child of p, then left-left rotation at p would suffice. This case always terminates the splay as v REACHES the root after this rotation. Zig-Zig: If p is not the root, p is the left child and v is also a left child, then a left-left rotation at g followed by a left-left rotation at p, brings v as an ancestor of g as well as p. Zig-Zag: If p is not the root, p is the left child and v is a right child, perform a left-right rotation at g and BRING v as an ancestor of p as well as g. Let us assume that the splay is performed at vertex v, whose parent and grandparent are p and g respectively. Then, the three rotations are named as: Zig: If p is the root and v is the left child of p, then left-left rotation at p would suffice. This case always terminates the splay as v reaches the root after this rotation. Zig-Zig: If p is not the root, p is the left child and v is also a left child, then a left-left rotation at g followed by a left-left rotation at p, brings v as an ancestor of g as well as p. Zig-Zag: If p is not the root, p is the left child and v is a right child, perform a left-right rotation at g and bring v as an ancestor of p as well as g. |
|