Question: . Consider a sorted array A = [ a 1 , a 2 , . . . , an ] of n distinct values: a
Consider a sorted array A a a an of n distinct values: a a an If X represents the variable being searched for, you also have the probabilities Pi and Qi as discussed in class Pi P rX ai for i n and Qi P rai X ai for i n and a and an Suppose you have written code for a dynamic programming algorithm such as the one described in class to compute the optimal binary search tree and you have all the necessary values that were computed: Wi j Ti j Ci j and Ri j Now suppose another value, y is added to the sorted array to obtain a new sorted array A and that y lies between at and at in the original array A For simplicity, we assume that t n That is A a a at y at ana a a t a t y a t at a n an Suppose further that we have values P i and Q i such that P t x and Q t z and Q t z Answer the following:
a Provide expressions for all the P i and Q i not given above, in terms of the ones given above and the Pi and Qi
b Describe a dynamic programming approach to compute the optimal binary search tree for A P Q Your approach should make maximum use of all the values already computed to find the optimal binary search tree for A P Q
c Under what circumstances will we have the situation where the newly inserted node, y is the root of the optimal binary search tree?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
