public class Node { private Node left; // (1) private int data; // (2) private Node right; // (3) // // A Node in a BTree has a left field (1) which is a // Node or empty (null). It contains an integer valued data (2) // and has a right field (3) again a Node or empty (null). // public Node(){ left = null; data = Integer.MIN_VALUE; right = null; } // // Default constructor. Left and right are null // and data has the smallest integer value. // public Node(int data){ left = null; this.data = data; right = null; } // // Construct a leaf node, with empty left and right // public Node(Node left,int data,Node right){ this.left = left; this.data = data; this.right = right; } // // Construct a new Node with a specified left, // data, and right. // public Node getLeft(){return left;} public int getData(){return data;} public Node getRight(){return right;} // // The 3 accessor methods for a Node // public void setLeft(Node l){left = l;} public void setData(int i){data = i;} public void setRight(Node r){right = r;} // // The 3 update methods for a node // public String toString(){return "" + data;} // // For printing a Node. It just converts its data // to a string // public boolean isLeaf(){return left==null && right==null;} // // A Node is a leaf if its left and right are empty // }