BinarySearchTree code.

computer science


Modify the author's BinarySearchTree code to implement some new methods as shown below.

    a) rotateRight

        Performs a single rotation on the node having the passed value.


        If a RotateRight on 100 is performed:

         100                 50

        /                 /   

       50   150    -->    40   100


    40                      45    150



    b) rotateLeft 

        Similar to above but instead a left rotation.

    c) copy

        Creates and returns a new tree that is a copy of the original tree.

Related Questions in computer science category