-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAVLNode.java
More file actions
57 lines (48 loc) · 770 Bytes
/
AVLNode.java
File metadata and controls
57 lines (48 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
public class AVLNode<T> {
private T data;
AVLNode<T> LeftChild;
AVLNode<T> RightChild;
AVLNode<T> Parent;
private int key;
int height;
public AVLNode(int key,T data)
{
this.data=data;
this.key=key;
LeftChild=new AVLNode<T>();
RightChild=new AVLNode<T>();
LeftChild.setParent(this);
RightChild.setParent(this);
height=0;
}
public AVLNode()
{
height=-1;
LeftChild=null;
RightChild=null;
}
public int Key()
{
return key;
}
public T getData()
{
return this.data;
}
public void setKey(int key)
{
this.key=key;
}
public void setParent(AVLNode<T> parent)
{
this.Parent=parent;
}
public boolean hasLeft()
{
return LeftChild.height!=-1;
}
public boolean hasRight()
{
return RightChild.height!=-1;
}
}