Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BinaryTree
- {
- private BinaryTree leftSubtree;
- private int label;
- private BinaryTree rightSubtree;
- BinaryTree(BinaryTree left, int val, BinaryTree right)
- {
- leftSubtree = left;
- label = val;
- rightSubtree = right;
- }
- public int getLabel()
- {
- return label;
- }
- public boolean isInOrder()
- {
- return leftSubtree.getLabel() < label
- && label < rightSubtree.getLabel();
- }
- public static void main(String[] args)
- {
- BinaryTree bt = new BinaryTree(null, 5, null);
- bt = new BinaryTree(bt, 7, null);
- System.out.println(bt.isInOrder());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement