0

I'm not sure how to construct a balanced search tree out of a few numbers and their associated search probabilities.

Please explain using the following example:

15 0.2
10 0.22
107 0.02
30 0.05
12 0.18
105 0.25
120 0.08
zoli
  • 20,452
  • 1
    A balanced search tree does not take the search probabilities into account. You are probably after an optimal search tree, which can be imbalanced. –  Apr 05 '17 at 09:30
  • The question asked for what u said also, which I can do. However, I do want an algorithm for constructing a/the balanced tree, even if it means ignoring their probabilities. – Ahmad Abdelzaher Apr 05 '17 at 09:37

1 Answers1

0

To build a balanced search tree, sort the array and recursively pick the medians.

10 12 15 30 105 107 120

10 12 15 30 105 107 120

10 12 15 30 105 107 120