Kenny
Posts: 5
Nickname: ck890
Registered: Sep, 2003
|
|
Re: Please Help!
|
Posted: Sep 22, 2003 12:26 AM
|
|
Thanks, but I have another problem now! Please help me again!
class AvlNode { NodeData element; AvlNode left; AvlNode right; int height;
AvlNode( NodeData theElement ) { this( theElement, null, null ); }
AvlNode( NodeData theElement, AvlNode lt, AvlNode rt ) { element = theElement; left = lt; right = rt; height = 0; }
public int getHeight( AvlNode t ) { if ( t == null ) return -1; else return t.height; }
public AvlNode rotateWithLeftChild( AvlNode k2 ) { AvlNode k1 = k2.left; k2.left = k1.right; k1.right = k2;
int x = getHeight(k2.left); int y = getHeight(k2.right); k2.height = max( x, y ) + 1; /* k1.height = max(height(k1.height), k2.height) + 1; return k1; */ } }
I assume int x = getHeight(k2.left); will assign the height of k2.left in x and it will be a integer, but the compiler said x is a AvlNode. I dont know what happen, and how can I fix it so that it will store the height of k2.left as integer in x. Thanks!
|
|