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;
} else {
Node temp = new Node();
temp = root;
while (temp != null) {
if (temp.data < data) temp = temp.right;
else {
temp = temp.left;
temp.data = data;
public int size () {
return countNode;

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

public static void main(String[] args) {

BSTree bs = new BSTree();


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

This article has been dead for over six months. Start a new discussion instead.