private int minCostRec(int input[],int freq[],int low,int high,int level){
        if(low > high){
            return 0;
        }
        
        int min = Integer.MAX_VALUE;
        for(int i=low; i <= high; i++){
            int val = minCostRec(input,freq,low,i-1,level+1) + 
                    minCostRec(input,freq,i+1,high,level+1)
                    + level*freq[i];
            if(val < min){
                min = val;
            }
        }
        return min;
    }
http://www.geeksforgeeks.org/dynamic-programming-set-24-optimal-binary-search-tree/
src/com/interview/dynamic/OptimalTreeSearch.java