Repository navigation
Expand file tree
/
Copy pathSiblingBinaryTreeNode.java
More file actions
67 lines (63 loc) · 1.81 KB
/
Copy pathSiblingBinaryTreeNode.java
File metadata and controls
67 lines (63 loc) · 1.81 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*Copyright (c) Dec 22, 2014 CareerMonk Publications and others.
* E-Mail : info@careermonk.com
* Creation Date : 2015-01-10 06:15:46
* Last modification : 2006-05-31
by : Narasimha Karumanchi
* File Name : SiblingBinaryTreeNode.java
* Book Title : Data Structures And Algorithms Made In Java
* Warranty : This software is provided "as is" without any
* warranty; without even the implied warranty of
* merchantability or fitness for a particular purpose.
*
*/
package chapter06trees;
public class SiblingBinaryTreeNode {
public int data;
public SiblingBinaryTreeNode left;
public SiblingBinaryTreeNode right;
public SiblingBinaryTreeNode nextSibling;
public SiblingBinaryTreeNode(int data){
this.data = data;
left = null;
right = null;
nextSibling = null;
}
public SiblingBinaryTreeNode(int data, SiblingBinaryTreeNode left, SiblingBinaryTreeNode right, SiblingBinaryTreeNode nextSibling){
this.data = data;
this.left = left;
this.right = right;
this.nextSibling = nextSibling;
}
public int getData() {
return data;
}
public void setData(int data) {
this.data = data;
}
public SiblingBinaryTreeNode getLeft() {
return left;
}
public void setLeft(SiblingBinaryTreeNode left) {
this.left = left;
}
public SiblingBinaryTreeNode getRight() {
return right;
}
public void setRight(SiblingBinaryTreeNode right) {
this.right = right;
}
public SiblingBinaryTreeNode getNextSibling() {
return nextSibling;
}
public void setNextSibling(SiblingBinaryTreeNode nextSibling) {
this.nextSibling = nextSibling;
}
// Sets the data in this BinaryTreeNode node.
public void setValue(int data) {
this.data = data;
}
// Tests whether this node is a leaf node.
public boolean isLeaf() {
return left == null && right == null;
}
}