Java Balancing Tree, I have no idea how to do this can some one help me PLEASE

• 05-26-2011, 10:06 PM
Jumanji245
Java Balancing Tree, I have no idea how to do this can some one help me PLEASE
(14pts) Below is the diagram to rebalance an AVL tree when the AVL condition is violated at the node P because of an insertion to the right of P's left child.

Complete the method doubleWithLeftChild(Node p) below that (1) rebalances the tree at P, (2) adjusts the heights of nodes whose children have changed, and (3) returns a reference to the new root node R of the rebalanced subtree.

Node doubleWithLeftChild(Node p)
{

}

where the Node structure is private class Node
{
public E data;
public Node left;
public Node right;
public int height;

public Node() { height = -1; }
public Node(E d) { data = d; height = 0; }
• 05-27-2011, 03:14 AM
Norm
Do you have the algorithm for this problem?
• 05-30-2011, 11:40 PM
Jumanji245
• 05-30-2011, 11:47 PM
Norm
Nice picture.
What is your design for the code you want to write?
• 05-31-2011, 12:28 AM
Jumanji245
Quote:

Originally Posted by Norm
Nice picture.
What is your design for the code you want to write?

I thought this was all i needed to do, this is all i he gave us
• 05-31-2011, 12:33 AM
Norm
Time to do some research and find an algorithm to solve the problem. I'm sure Google will find one.
Once you have the algorithm, then you can think about how to turn it into java code.
• 05-31-2011, 04:18 AM
pbrockway2