Advanced Data Structures (COP5536)

Solution - Exam 3, Sample 3 


1. (a) A splay tree

 

   (b) split with respect to node with element 10

 

2. (a)

 

   (b) delete 6

 

 

  

3. 
   (a) 

 

   (b) Start from root, hight logK, when enumearte a node s++.

 

4.

   (a) Assume k1->x, k2->y, k3->z. first sort the n records on x(k1). Then build a tree like this:

 

   (b) Start at the root, recursively visite node in such way compare the z-range of the query l_z and u_z to the range of the node.

 

   (c)

 

5.

If X is the NW or SW child of its parent, then its east-neighbor is NE or SE child of the parent, repectively.
If X is the NE or SE child of its parent, we have to recursively find the east neighbor.

The algorithm is below:::

Procedure East_Neigbhor(X)
{
    if X is the root then retrun null;
    if X = NW-child of parent(X) 
       return NE_child of parent(x);
    if X = SW-child of parent(X) 
       return SE-child of parent(x);
    j <-- East_Neighbor(parent(X));  //recursive call
    if j = null or leaf 
        return j;
    else if (X is NE-child of parent (X))
        return NW-child of j;
    else if (X is SE-child of parent(X))
        return SW-child of j;
}