WEEK 10

 

Trees cont.

1.      root is null

2.      deleting root

o       with no left node

o       with

3.      deleting a node with no left node

4.      deleting node (want to move up rightmost of left side or leftmost of right side to take this place)

o       Need to have a pointer to the parent node

o       Deleting once we’ve found the node:

1.      return true

2.      root = root.right
or replace with left rightmost

3.      if (ptr == parentptr.left)

parentptr.left = ptr.right;

                                                else

                                                            parentptr.right = ptr.right;

4.      ptr.data = ptr.left.getrightmostdata();

ptr.left = ptr.left.removerightmost();

·        Performance

·        Time analysis