-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeNode.java
More file actions
53 lines (42 loc) · 1.01 KB
/
Copy pathTreeNode.java
File metadata and controls
53 lines (42 loc) · 1.01 KB
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
package datastructures;
import model.Voter;
/**
* Node for the Binary Search Tree that stores Voter information.
* The tree is ordered by Government ID for O(log n) search time.
*/
public class TreeNode {
private Voter voter;
private TreeNode left;
private TreeNode right;
private int height; // For AVL balancing
public TreeNode(Voter voter) {
this.voter = voter;
this.left = null;
this.right = null;
this.height = 1;
}
public Voter getVoter() {
return voter;
}
public void setVoter(Voter voter) {
this.voter = voter;
}
public TreeNode getLeft() {
return left;
}
public void setLeft(TreeNode left) {
this.left = left;
}
public TreeNode getRight() {
return right;
}
public void setRight(TreeNode right) {
this.right = right;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
}