use some tricks to decrease the time complexity of optimal_binary_search_tree