Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CLO4 - Lab 2 Solution

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

CLO4- Trees Worksheet 1

1. Which of these graphs are trees?

A tree because it is connected Not a tree because it is not This graph is a tree because it is
has no simple circuits. connected. connected has no simple
circuits.

Not a tree because it has a This graph is a tree because Not a tree because it has a
simple circuit. it is connected has no simple simple circuit.
circuits.

CIS 2203 Page 1 of 5


CLO4- Trees Worksheet 1 Solutions
2. Answer these questions about the rooted tree illustrated below:

a) Which vertex is a root?


a is the root of the tree.

b) Which vertices are internal?

The internal vertices are a; b; c; d; f; h; j; q; t.

c) Which vertices are leaves?


The leaves are e; g; i; k; l; m; n; o; p; r; s; u.

d) Which vertices are children of j?

The children of j are q and r.


e) Which vertex is the parent of h?
The parent of h is c.
f) Which vertices are siblings of o?
The sibling of o is p.
g) Which vertices are ancestors of m?
The ancestors of m are f; b; a.
h) Which vertices are descendants of b?
The descendants of b are e; f; l; m; n.

2
CLO4- Trees Worksheet 1 Solutions
3. Draw the subtree of the tree in Exercise 3 that is rooted at

a. root c:

b. root e:

4. Is the rooted tree in Exercise 2 a full m-ary tree for some positive integer m?

This m-ary tree is valid for all m ≥ 3. However, the tree is not a full m-ary tree because it has
vertices that have 3, 2, or 1 children.

5. How many edges does a tree with 10000 vertices have?

Use theorem 2. A tree with n vertices has n − 1 edges. 10000 − 1 = 9999 edges.

6. How many edges does a full binary tree with 1000 internal vertices have?

A full binary tree has two edges for each internal vertex. So we’ll just multiply the number of
internal vertices by the number of edges.
1000 *· 2 = 2000 edges

3
CLO4- Trees Worksheet 1 Solutions

7. What is the outcome of inorder traversal on this tree?

Inorder: 2, 3,4, 5, 6, 7, 8 , 9, 11, 12, 15,19, 20.

4
CLO4- Trees Worksheet 1 Solutions

You might also like