Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dynamic Programming 1. (10 pts) Let B(n) be the number of different binary search trees containing the n keys 1, 2, . For this problem

Dynamic Programming

image text in transcribed

1. (10 pts) Let B(n) be the number of different binary search trees containing the n keys 1, 2, . For this problem you will develop a dynamic programming algorithm that, given n, calculates B(n). Note that B(l) = 1 since there is only one one-node binary tree. For two nodes B(2) = 2 (either node can be root, and there is only one binary search tree consistent with each choice). (a) (I pt) Calculate by hand B(3). (b) (1 pt) How many n = 6 key binary trees are there with keys {1, 2, 3, 4, 5, 6} and key 3 at root (so the left subtree has two nodes, and the right one has 3 nodes) are there? (c) (3 pts) Construct a recurrence for B(n), I expect something with a sum. Include boundary con- ditions in your recurrence; what is a convenient boundary value for B(O)? Briefly justify (formal proof not required) that your recurrence computes the correct value. (d) (4 pts) Give an iterative (bottom up) algorithm based on the recurrence that computes B(n) by filling in a table. (e) (1 pt) What is the running time of your iterative algorithm as a function of n (use asymptotic notation)?

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

Step: 3

blur-text-image

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

What activities do you enjoy when you are not working?

Answered: 1 week ago