public int binarySearchTail (ArrayList<String> word, String key,int first, int last){
        int mid = first + ((last-first)/2);

        if (word.size() == 0){
            return 0;
        }
        if (first>last){
            return mid;
        }
        if (key.equals(word.get(mid))){
            return mid;
        }
        if(word.get(mid).compareTo(key)>0){

            return binarySearchTail(word, key, first, mid-1);
        }
        if(word.get(mid).compareTo(key)<0){
            return binarySearchTail(word,key,mid+1, last);
        }
        else{
            return mid;
        }
    }