• edited by
7,124 views
46 46 votes

First, consider the tree on the left.

  

On the right, the nine nodes of the tree have been assigned numbers  from the set $\left\{1, 2,\ldots,9\right\}$ so that for every node, the numbers in its left subtree and right subtree lie in disjoint intervals (that is, all numbers in one subtree are less than all numbers in the other subtree). How many such assignments are possible? Hint: Fix a value for the root and ask what values can then appear in its left and right subtrees.

  1. $2^{9}=512$
  2. $2^{4}.3^{2}.5.9=6480$
  3. $2^{3}.3.5.9=1080$
  4. $2^{4}=16$
  5. $2^{3}.3^{3}=216$

4 Answers

Best answer
60 60 votes

Option is B.

for every node -all numbers in one subtree are less than all numbers in the other subtree .


Firstly chose a value for root $- 9$ elements = $\mathbf{9}$ ways

Now, we hv $\mathbf{8}$ elements left - we hv to chose $\mathbf{3}$ for left subtree & $\mathbf{5}$ for right subtree.

Note: Here we can either chose $3$ nodes from beginning or end out of 8 elements we have ! $= \mathbf{2}$ ways


Now,we hv $3$ elements for left subtree & $5$ for right(Consider subtrees of subtree).

Left Subtree :

      whatever way we place , always one side is smaller than other {$6$ is smaller than $8$ in above example given in question} so, total ways $= \mathbf{3!} $ {three places put one by one} $=\mathbf{6}$ ways


Right Subtree :

Right subtree has two more sub-trees ,so that elements on one side should be smaller than other **

Steps :

  1. Select one element for root $=\mathbf{5}$ ways
  2. $4$ elements left ,Select one element for left $=\mathbf{2}$ ways {Either we can chose from left or right}
  3. $3$ elements left, for right subtree $=\mathbf{3!}$ ways $=\mathbf{6}$ ways

Total ways $= 9*2* 3! * 5 * 2 * 3! = 2^4* 3^2 * 5 * 9 = 6480 =$ B (Ans) 

• edited by
21 21 votes

Based on concepts of Combination

Based on concepts of Combination

7 7 votes
1 2 3 4 5 6 7 8 9                 no. of ways to select a root  = 9     ,   

after chosing root , choose right most 3 element fron this 1 to 9 series for left sub tree ( as elements of left sub tree should be greater than all elements of rignt subtree)   .   put thsese 3 elements in 3 nodes of left subtree in 3! ways

now we have left with 5 elements for right subtree . put these 5 elements in right subtree in 5! ways

so total trees ==  9 *5!*3!= 6480
Answer:
Position:
Show:

Related questions

33 33 votes
5 answers 5 answers
7.2k
7.2k views
Misbah Ghaya asked Dec 5, 2015
7,211 views
There is a set of $2n$ people: $n$ male and $n$ female. A good party is one with equal number of males and females (including the one where none are invited). The total n...
22 22 votes
8 answers 8 answers
6.4k
6.4k views
Misbah Ghaya asked Dec 5, 2015
6,389 views
A $1 \times 1$ chessboard has one square, a $2 \times 2$ chessboard has five squares. Continuing along this fashion, what is the number of squares on the regular $8 \time...
25 25 votes
5 answers 5 answers
4.5k
4.5k views
Misbah Ghaya asked Dec 8, 2015
4,486 views
Consider the following grammar (the start symbol is $E$) for generating expressions.$E \rightarrow T - E \mid T + E \mid T$$T \rightarrow T * F \mid F$$F \rightarrow 0 \m...
15 15 votes
3 answers 3 answers
3.4k
3.4k views
Misbah Ghaya asked Dec 8, 2015
3,417 views
Consider the following concurrent program (where statements separated by | | with-in cobegin-coend are executed concurrently).x:=1 cobegin x:= x + 1 || x:= x + 1 || x:=...