Write a program that implements the BinarySearchTree interface given below . The type of data stored in this tree is Integer. You are free to use any type of implementation;

public interface BinarySearchTree {
   public void insert(Integer data);
   public int size();
   public int height();
   public boolean contains(Integer target);
}


class Node {
Node left, right, next;
Integer data;
Node () {
left = right = null;
data = 0;
}
}
public class BSTree extends Node implements BinarySearchTree {
static Node root;
static int countNode;
/**
* Creates a new instance of BSTree
*/
public BSTree() {
root = null;
}
public void insert(Integer data) {
if (root == null) {
root.data = data;
countNode++;
} else {
Node temp = new Node();
temp = root;
while (temp != null) {
if (temp.data < data) temp = temp.right;
else {
temp = temp.left;
}
temp.data = data;
countNode++;
}
}
}
public int size () {
return countNode;
}

public int height() {}
public boolean contains (Integer target) {}

public static void main(String[] args) {

BSTree bs = new BSTree();
bs.insert(12);
bs.insert(3);
bs.insert(14);
}

}

Can any one help me in writing contains and height method ?

wasn't it obvious in the other threads? we can, but we won't. not only do you refuse to do any work yourself, but you ignore answers given to you.

stop copy-pasting your homework instructions here, try yourself and then (if necessary) show us what you tried and ask us where you went wrong

Seemingly not soooooo Urgent, or you'd be working on it rather than simply whining/posting about it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.