> BinarySearchTree Program not running correctly?(Java)?

BinarySearchTree Program not running correctly?(Java)?

Posted at: 2014-12-18 
When i try to run this program i get an array index out of bound exception. This program depends on the program that I attached as a photo.

-----------------------------------------------------------------

import java.util.Random;

public class BinaryMain{

public static void main(String[] args) throws Exception{

int n=Integer.valueOf(args[0]);

BinarySearchTree s=new BinarySearchTree();

// Random test

Random r;

// insert()

r=new Random(0);

for(int i=0; i
// find()

r=new Random(0);

int m=0;

for(int i=0; i
if (!s.find(m=r.nextInt(Integer.MAX_VALUE)))

throw new Exception(m+" not found");

}

System.out.println("random "+n+" "+s.getCost());



s=new BinarySearchTree();

// Sequential test

// insert()

for(int i=0; i
// find()

for(int i=0; i
if (!s.find(i))

throw new Exception(i+" not found");

}

System.out.println("sequential "+n+" "+s.getCost());

}

}

-----------------------------------------------------------------

How can I fix it?