You are on page 1of 5

HOMEWORK

Nguyen Minh Tri


ITITIU14098

4/693
a)
b)
c)
d)
e)
f)
g)
h)

The root of the tree is a


The internal vertices of the tree are a,b,d,g,h,i,o.
The leaves of the tree are c,f,j,k,l,m,n,p,q,r,s.
There are not children of j.
The parent of h is d
The siblings of o is p
The ancestors of m are g,b,a
The descendants of b are e,f,g,m,l,k,j.

6/694
The rooted tree in exercise 4 is not full m-ary tree because we have 2(j,k) or 3(q,r,s) chidrens in a
tree.

10/694
a) The subtree with root a
a
b
d
c

b) The subtree with root c

c
c) The subtree with root e
e

22/694
The chain letter can be represented using a 5-ary tree. Because 10000 people send out the letter,
the number of internal vertices is 10000.
Therefore the number of people have seen letter is
n=5.10000+1=50001.
The number of people have receive letter but not send out is 50001-10000=40001 people.

28/694
In m-ary tree we have:
At level 0, we have 1 vertex in tree
At level 1, we have m vertices in tree
At level 2, we have m2 vertices in tree
Therefore,
1+m+m2+ + mh= (mh+1-1)/(m+1)
And leaves in m-ary tree is mh
32/694
Tree can be used to the represent of contents of the book is :
Level 1of tree is chapters
Level 2 of tree is sections

Level 3 of tree is subsections


2/708

oenology

campanology

phrenology
ichthyology

alchemy
limnology

ornithology

astrology
6/708
Weighings of a balance scale are needed to find a lighter counterfeit coin among four coins is
[log34]=2
Describe:
We use tree to find counterfeit coin. There are 2-ary tree. We have 4 coin 1,2,3,4. First, we compare
1 and 2 with 3 and 4. If 1 and 2 is lighter, it is the counterfeit. On the other hand, the counterfeit is 3
and 4.
20/709
a) a:01, e: 0, t:101, s: 100
0

1
1

e
0

1
t

b) a:1, e:01, t:001, s:0001, n:00001

0
0
1

a
1

0
1

1
n

c) a:1010, e:0, t:11, s:1011, n:1001, i:1001

0
e

t
0

1
1

0
1
1

0
n

22/709
a:001, b:0001, e:1, r:0000, s:0100, t:001, x:01010
a)
b)
c)
d)

The word represented by 01110100011: test


The word represented by 0001110000: beer
The word represented by 0100101010: sex
The word represented by 01100101010: tax

4/722
a)
b)
c)
d)
e)

Level of v is 5
Address of the parent of v is 3.4.5.2
The least number of sibling v can have is 3 ( not including it self)
The smallest possible number of vertices in T if v has address is 19 vertices.
the other addresses that must occur is:

3.4.5.2.1, 3.4.5.2.3, 3.4.5.2.3


3.4.5.1, 3.4.5.2
3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.4.5
3.1, 3.2, 3.3, 3.4.
3
2

1
0
8/723
A preorder traversal visits the vertices of the given ordered rooted tree is d, I, m, n, o, j, e, b, f, g, k,
p, l, h, c, a.
12/723
The order are the vertices of the ordered rooted tree in Exercise 9 visited using an inorder traversal
is: k, e, l, m, b, f, r, n, s, g, a, c, o, h, d, I, p, j, q.
14/723
The order are the vertices of the ordered rooted tree in Exercise 7 visited using a postorder traversal
is: d, I, m, n, o, j, e, b, f, g, k, p, l, h, c, a.
18/723
a) the expression using a binary tree:

b) This expression in prefix notation :

You might also like