Question

(a) How many different shapes can a BST be in, if its height = 3? (b)...

(a) How many different shapes can a BST be in, if its height = 3?

(b) Find the average depth of a node in a BST of height = 3, assuming that every shape of the BST is equally likely.

~Answer might be 1.5

(c) Give a strong argument as to whether all BST shapes at height = 3 are equally likely.

I would like to understand how the answers are calculated i.e. what formula please.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) How many different shapes can a BST be in, if its height = 3?

b) Find the average depth of a node in a BST of height = 3, assuming that every shape of the BST is equally likely.

c) Give a strong argument as to whether all BST shapes at height = 3 are equally likely.

Suppose the height of a BST is h, then total number of nodes nis

n = 2h+1 -1(for maximum number of nodes)

n = h + 1 for minimum number of nodes)

Now, if we consider for minimum numbers of nodes, then for h = 3

n= (h+1) = (3 +1) = 4

Now, with 4 nodes, total

(2n)! - numbers of BST of different shapes are possible.

putting n = 4 at the above equation we get

(2 * 4)! (4 + 1)!*4! 8! 5!*4! = 14

So, 14 different shaped BST is possible.

for average depth of the node with minimum nodes = n = (n + 1) = (3 + 1) = 4

total depth for all n nodes =>i*1 WI

now for depth = height = h = 3, total depth is

> i*1=0*1+1*1+2*1 +3* 1 = 1 + 2 + 3 = 6

6 = 1.5 average depth = total_depth 6 no of nodes n+1 =

if we consider maximum number of nodes, then n = 2h+1 - 1 if we consider minimum number of nodes, then n = h + 1 for maximum number of nodes, maximum possible BST will be (2n)! = 9694845 where, n = 2h+1 - 1 = 23+1 - 1 = 15 (n + 1)! *n! again for maximum number of nodes, total depth = total depth = 31.26 i + 2 for h = 3 it will be i* 21 = h. 2h+1 - 2+1 +2 = 3.24 -24 +2 = 48 - 16 + 2 = 34 n will be n = 2h+2 - 1 34 So average depth = 2h+1 34 5

So if we consider maximum or minimum number of nodes, according to that total number of BST

and the average depth will be changed. here in the a) b) we worked with minimum numbers of nodes

forn = (h + 1), but at c) we show it with maximum 2h+1 - Inumber of nodes.

Add a comment
Know the answer?
Add Answer to:
(a) How many different shapes can a BST be in, if its height = 3? (b)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • must be coded in c++ without any STL libraries sadly :( so im struggling on this...

    must be coded in c++ without any STL libraries sadly :( so im struggling on this problem, any help would be greatly appreciated, thanks in advance! :) assignment is due tomorrow and im really struggling on this last question :( a. Begin by implementing a BST for integers. The underlying structure is a linked list. You need these methods: i. BST(); -- Constructor ii. void put (int) – Inserts a value into the BST. iii. Void put(int[] a) – Inserts...

  • The purpose of this assignment is to demonstrate how different scripting languages can interact to produce...

    The purpose of this assignment is to demonstrate how different scripting languages can interact to produce common results that you see on the web every day. Create a web form that adds a journal entry to your webserver blog. The form should include a title field, along with a file upload prompt. Review the information in "IT/Python Web Forms & UI," prior to beginning the assignment. Assignment Instructions: Using your homepage from Topic 3, create a Python script that prompts...

  • Multivariable need help and some word explanation Iam a little bit confused on how to set up hy 2 dr xplain why the answers to parts (a) and (b) give the formula we want. e Distance Walked to...

    Multivariable need help and some word explanation Iam a little bit confused on how to set up hy 2 dr xplain why the answers to parts (a) and (b) give the formula we want. e Distance Walked to an Airport Gate orts up in a terminal like points along a line. If you arriv , departure gates are often lined ate and proceed to another gate for a connecting flight, what propor inal will you have to walk, on average?...

  • RRM # 2 (ends at for organization, and they force their ideas to fit it. Along...

    RRM # 2 (ends at for organization, and they force their ideas to fit it. Along the way, their perfectly good ideas get mangled or lost). Purple # 2 1. Create a simple outline of the bulleted points. RRM # 3(ends at it doesn't begin to explore how or why something happened.) Purple # 3 2. Does this relate to you? Do you write like this? 3. Predict what will come next. RRM # 4 (ends at opened are, in...

  • can you please give feed back to this.. like add something or give a comment about...

    can you please give feed back to this.. like add something or give a comment about the following posts. 1) Profit Margin = NetincomeSales Profit margin is very useful in analyzing the financial health of the firm because it indicates how much money is generated per every dollar in sales. A higher profit margin means there are low expense ratios relative to sales. In other words, it tells us how a company uses its income. When a company has a...

  • Can Dogs Understand Human Cues? EXPLORATION Dogs have been domesticated for about 14,000 years. In that...

    Can Dogs Understand Human Cues? EXPLORATION Dogs have been domesticated for about 14,000 years. In that time, have they been able to develop an understanding of human gestures such as pointing or glancing? How about simi lar nonhuman cues? Researchers Udell, Giglio, and Wynne tested a small number of dogs in order to answer these questions. In this exploration, we wll first see whether dogs can understand human gestures as well as nonhuman gestures. To test this, the researchers positioned...

  • A private university is considering how it should best go about recovering the outstanding tuition balances...

    A private university is considering how it should best go about recovering the outstanding tuition balances owed by students who leave the school. There are currently 100 students who left the school this quarter who owe an average of $6000 each to the university. The school has several options for how it can go about recouping the amount that these former students owe. First, it can immediately sell these debts to a third-party collections agency for 50 cents on the...

  • Hello can someone please help me with this queshtion its 3 time I post this please....

    Hello can someone please help me with this queshtion its 3 time I post this please. The queshtion is in the buttom. Im really confused from what to choose I have been second guessing myself. The Economics of Immigration Paul Krugman In 1970, only 5% of U.S. workers had been born abroad. By 2016, however, 17% of American workers had immigrated to the United States, both legally and illegally. (1) Figure 1: Percentage of U.S. labor force that is foreign-born...

  • Python program This assignment requires you to write a single large program. I have broken it...

    Python program This assignment requires you to write a single large program. I have broken it into two parts below as a suggestion for how to approach writing the code. Please turn in one program file. Sentiment Analysis is a Big Data problem which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like to have a program that could look at the text "The film was a breath of...

  • Case Study: Managers Challenge When Dealing With Change Ying was struck when one of the lecturers...

    Case Study: Managers Challenge When Dealing With Change Ying was struck when one of the lecturers on her postgraduate module talked about how managers often struggle when companies undergo changes such as mergers, and how they often fail to address their own difficulties. Since it was time for her to start thinking about her postgraduate research project, she thought that understanding the challenges managers face in looking after the organization and its employees during change processes would be a worthwhile...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT