Vous êtes sur la page 1sur 6

Name : Phm Minh Qun

ID : ITITIU14083
LAST HOMEWORK

a)
b)
c)
d)
e)
f)
g)
h)

Exercise 4 :

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.

Exercise 6 :

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

Exercise 10 :

a) The subtree with root a


a

b
c
e

f
j

b) The subtree with root c

c) The subtree with root e


e

Exercise 22 :
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.
So, the number of people have seen letter is
n=5.10000+1=50001.
The number of people have received letter but not send out is 5000110000 = 40001 people.

Exercise 28 :
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

So,
1+m+m2+ + mh= (mh+1-1)/(m+1) and leaves in m-ary tree is mh

Exercise 32 :

Tree can be used to the represent of contents of the book is :


Level 1 of tree is chapters
Level 2 of tree is sections
Level 3 of tree is subsections

Exercise 2 :
oenolo
gy
campanolo
gy
alche

astrolo

phrenolo
gy
ichthyolo
limnolog

ornitholo

Exercise 6 :
Weighings of a balance scale : [log34]=2
We have :

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. So , the
counterfeit is 3 and 4.

Exercise 20 :

a) a:01, e: 0, t:101, s: 100


0

1
1

e
0

b)

0
a:1, e:01, t:001, s:0001, n:00001
0
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

Exercise 22 :
a:001, b:0001, e:1, r:0000, s:0100, t:001, x:01010

a) The word represented by 01110100011: test


b) The word represented by 0001110000: beer
c) The word represented by 0100101010: sex
d) The word represented by 01100101010: tax

Exercise 4 :
a) At what level is v?
Level 5.
b) What is the address of the parent of v?
3.4.5.2
c) What is the least number of siblings v can have?
V can have 3 other siblings not including it self .
d) What is the smallest possible number of vertices in T if v has
this address?
We have 19 vertices in the tree.
e) Find the other addresses that must occur.
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

Exercise 8 :
preorder traversal : Root Left Right => d, I, m, n, o, j, e, b, f, g, k, p, l,
h, c, a.

Exercise 12 :
Inorder traversal : Left Root Right => k, e, l, m, b, f, r, n, s, g, a, c, o, h,
d, I, p, j, q.

Exercise 14 :
Postorder traversal : Left Right Root => d, I, m, n, o, j, e, b, f, g, k, p, l,
h, c, a.

Exercise 18 :
a)

P
b)

Prefix notation = preorder : Root Left Right => P Q P Q and


PQPQ
c)
Postfix notation = postorder : Left Right Root => P Q P Q and
PQP Q
d)
Infix notation = inorder : Left Root Right => ( P Q ) ( P Q )
and (( P (Q P))Q

Exercise 2 :

We can remove : (a, b) ; (b, c)

Exercise 6 :

We can remove : (a, e) ; (a, h) ; ( b, g) ; (c, f) ; (c, j) ; (d, k) ; (e, i) ; (g, l) ;


(h, l) ; (I, k).

Exercise 10 :
case 1 :
c
a

d
case 2 :
c
a

d
case 3 :
c
a

b
d
case 4 :
c

b
d

Vous aimerez peut-être aussi