Let''s examine what information we are given:
1) We are working with a binary search tree.
A binary search tree is a graphical representation of every possible path that a binary search can take on given data. However, there are two things to keep in mind here. 1) A binary search only works with sorted data. If the data isn''t sorted, then we can''t do a binary search, which is implied. I''m not saying that the data is sorted
iif it''s a binary tree. 2) In a binary search, the first node checked represents the mid-value of the entire set of data, and each consequetive node represents the mid-value of each subset of data. Thus, the following trees with A < B < C:
A \ B / \ CA \ B / \C
Or any other related trees are not valid representations of a binary search tree, because they incorrectly represent the progession of a binary search. The root has to be the middle value of the set of data, because that''s how a binary search works. In this case, it
has to be B. Each sub-tree then has to be in a definite relationship with it''s root. In the end, a
binary search tree lends itself to be balanced, simply due to the nature of a binary search.
2) We are trying to minimize the expected number of nodes to be examined.
To minimize the expected number of nodes to reach any value we search for, we put the values of highest probability where they will be examined before those of lesser probability. We proved this with the linked list question. A binary search is the same, only instead of having single elements linked directly to one another, where it takes
n examinations to reach the
nth element, we have levels of the tree linked to each other, where it takes
n examinations to reach the
nth level of the tree. This is also what makes a binary search a lot better than a linear search in a lot of cases - each level in a tree contains possibly more than one element, yet it only takes a single examination to traverse a level. Given probabilities A < B < C < D < E < F < G, any one of these trees would work best (discounting integer rules and such):
D / \ B F / \ / \A C E G D / \ B F / \ / \C A G E D / \ F B / \ / \G E A C
Thus each sub-level changes (and takes its children with it), but inter-level juxtapositioning can change fluidy, and we can still assume all data is sorted, because we have no specifics on that.