Optimal Binary Search Trees
Explore the concept of optimal binary search trees by understanding how to minimize total search time based on key access frequencies. Learn the recursive cost function and how backtracking applies to select the root for efficient search performance. This lesson guides you through constructing trees that balance search costs beyond simple tree height considerations.
We'll cover the following...
Introduction to optimal binary search trees
Our final example combines recursive backtracking with the divide-and-conquer strategy. Recall that the running time for a successful search in a binary search tree is proportional to the number of ancestors of the target node. As a result, the worst-case search time is proportional to the depth of the tree. Thus, to minimize the worst-case search time, the height of the tree should be as small as possible; by this metric, the ideal tree is perfectly balanced.
In many applications of binary search trees, however, it is more important to minimize the total cost of several searches rather than the worst-case cost of a single search. If ...