-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathENode.java
More file actions
51 lines (47 loc) · 1.21 KB
/
ENode.java
File metadata and controls
51 lines (47 loc) · 1.21 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
/**
* An external node representation of a tree. Nodes of this type is used as a placeholder
* for further insertion. In case of insertion, the external node must be replaced by another
* internal nodes having two external nodes as children.
*
* @param <T> element type for the node
*/
public class ENode<T> extends Node<T> {
/**
* Creates an instance of an external node with its parent set to <tt>parent</tt>.
* Both children are <tt>null</tt>.
*
* @param parent the parent node
*/
public ENode(Node<T> parent) {
super(parent);
left = null;
right = null;
value = null;
}
/**
* Creates an instance of an external node with its parent set to <tt>null</tt>.
* Both children are <tt>null</tt>.
*/
public ENode() {
super(null);
left = null;
right = null;
value = null;
}
/**
* Check whether the position is an internal node.
* @return false
*/
@Override
public boolean isInternal() {
return false;
}
/**
* Check whether the position is an external node.
* @return true
*/
@Override
public boolean isExternal() {
return true;
}
}