Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * TreeNode.
- */
- class TreeNode {
- private int data;
- private TreeNode leftNode;
- private TreeNode rightNode;
- public TreeNode(int nodeData) {
- data = nodeData;
- leftNode = rightNode = null;
- }
- }
- /**
- * Tree (of TreeNodes).
- */
- class Tree {
- TreeNode root;
- /**
- * Adds the specified value to the Tree. * @param value an int
- */
- public void add(int value) {
- TreeNode temp = new TreeNode(value);
- if (root == null)
- root = temp;
- else
- add(root, temp);
- }
- /*
- * Implement this helper method.
- *
- * @param currentNode
- *
- * @param newNode
- */
- private void add(TreeNode currentNode, TreeNode newNode) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement