Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer correctly....I have already received completely bogus answers. Find the cost and the structure of an optimal binary search tree for a set of

image text in transcribedPlease answer correctly....I have already received completely bogus answers.

Find the cost and the structure of an optimal binary search tree for a set of 7 keys with the following probabilities: p[..] = {0.16, 0.12, 0.14, 0.07, 0.15, 0.17, 0.19}. Use the algorithm from the class. BST(p, n)//Input: array p of n probabilities//Output: array c and root 1 for i = 1 to n + 1 2 c[i, i - 1] = 0//empty tree 3 for d = 0 to n - 1//d is the difference j - i 4 for i = 1 to n - d 5 j = i = d 6 c[i, j] = infinity 7 sum = 0 8 for r = i to j 9 sum+ = p_r 10 x = c[i, r - 1] + c[r + 1, j] 11 if c[i, j] > then c[i, j] = x and root[i, j] = r 12 c[i, j] + = sum 13 return c[..] and root [..] c[i, j] = {0 if j = i - 1, min_ i lessthanorequalto r lessthanorequalto j {c[i, r - 1] + c[r + 1, j] + sigma_t = 1^j pt} if i lessthanorequalto j. Please with full explanation of steps. Partial work/incorrect answers will not receive positive Feedback. Find the cost and the structure of an optimal binary search tree for a set of 7 keys with the following probabilities: p[..] = {0.16, 0.12, 0.14, 0.07, 0.15, 0.17, 0.19}. Use the algorithm from the class. BST(p, n)//Input: array p of n probabilities//Output: array c and root 1 for i = 1 to n + 1 2 c[i, i - 1] = 0//empty tree 3 for d = 0 to n - 1//d is the difference j - i 4 for i = 1 to n - d 5 j = i = d 6 c[i, j] = infinity 7 sum = 0 8 for r = i to j 9 sum+ = p_r 10 x = c[i, r - 1] + c[r + 1, j] 11 if c[i, j] > then c[i, j] = x and root[i, j] = r 12 c[i, j] + = sum 13 return c[..] and root [..] c[i, j] = {0 if j = i - 1, min_ i lessthanorequalto r lessthanorequalto j {c[i, r - 1] + c[r + 1, j] + sigma_t = 1^j pt} if i lessthanorequalto j. Please with full explanation of steps. Partial work/incorrect answers will not receive positive Feedback

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Which is the more general term, CSCWS or GDSS? Explain.

Answered: 1 week ago

Question

What are the pros and cons when 2 major restaurant chains merge?

Answered: 1 week ago

Question

Determine the amplitude and period of each function.

Answered: 1 week ago

Question

5. To determine the financial benefits and costs of the program.

Answered: 1 week ago