build a bst as an array using recursion?
- by Jack B
String[] dictionary = new String[dictSize]; //arrray of strings from dictionary
String[] tree = new String[3*dictSize]; //array of tree
void makeBST() {
recMakeBST(0, dictionary.length-1);
}//makeBST()
int a=0;
void recMakeBST(int low, int high) {
if(high-low==0){
return;
}
else{
int mid=(high-low)/2;
tree[a]=dictionary[mid];
a=a+1;
recMakeBST(low, mid-1);
a=a+1;
recMakeBST(mid+1, high);
}
}