0% found this document useful (0 votes)
52 views8 pages

Tutorial 5 (IDHAM IZZUDIN)

The document poses several questions about binary trees, binary search trees, and expression trees. It asks the reader to list properties of an example tree, construct a tree from traversal orders, insert and delete values from a binary search tree while showing the results, and evaluate an expression tree. [SUMMARY

Uploaded by

Zhen Wei
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views8 pages

Tutorial 5 (IDHAM IZZUDIN)

The document poses several questions about binary trees, binary search trees, and expression trees. It asks the reader to list properties of an example tree, construct a tree from traversal orders, insert and delete values from a binary search tree while showing the results, and evaluate an expression tree. [SUMMARY

Uploaded by

Zhen Wei
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Question 1

1. List All the leaf nodes.


H, I, L, K

2. List all the parent nodes


A, B, C, D, E, F

3. List all the siblings


B, C
D, E
F, G
H, I, J, K

4. What is the height of the tree?


The height of the tree is 5.
5. Is the Above binary tree complete? Justify your answer.

Question 2

a) Aa

b)
Question 3

Trees are used extensively in computer science to represent algebraic formula; as an efficient
method for searching large, dynamic lists; and for such diverse applications as artificial intelligence
systems and encoding algorithms

(a) Define binary tree.

Binary tree is a tree data structure whereby each node consists up to two child nodes
and hence, creating the branches of the tree.

(b) Given the list of nodes for a binary tree in two different orders:

Preorder: A B D E G H J K L M C F I
Inorder: D B G E H K J M L A C I F

i. Construct (draw manually) the binary tree.

ii. Give the postorder traversal for the binary tree constructed.

Postorder traversal : D G M L K J H E B F I C A

c) Consider the list of integer numbers below:

62, 31, 70, 91, 25, 11, 49, 61, 73, 25.
i) Show the result of inserting the numbers in the same order specified above into an
initially empty binary search tree. Note that you need to show how the binary search
tree looks like after each number is inserted.

ii) Based on the binary search tree you created in question (c)i., draw manually TWO (2)
possible binary search trees after 62 is deleted.
Question 4

Trees are used extensively in computer science to represent algebraic formula; as an efficient
method for searching large, dynamic lists; and for such diverse applications as artificial intelligence
systems and encoding algorithms

a) Show the trees that result from the following sequence of insertions into a binary search
tree:

62, 31, 70, 91, 25, 11, 29, 61, 73, 36.

b) Given the following orders of traversal of a binary tree, recreate the tree:

Postorder : G,D,B,H,I,E,F,C,A
Inorder : D,G,B,A,H,E,I,C,F
c) Consider the following binary search tree in Figure 6:

i) Delete 61

ii) Delete 75

iii) Delete 30
iv) Insert 85

Question 5

Answer :
i) + * 3 / + 7 1 4 – 17 5
ii) 3 7 1 + 4 / * 17 3 - +
iii) 3 * 7 + 1 / 4 + 17 – 5
iv) 3 * 7 + 1 / 4 + 17 – 5 = 33.25

You might also like