100% found this document useful (1 vote)
55 views4 pages

Name: Student No.: Group:: Csc248 - Fundamentals of Data Structures Tree: Tutorial

This document contains a tutorial on trees with 4 questions. It discusses binary trees, their traversals (pre-order, in-order, post-order), heights, leaves, and ancestors. Examples of traversing sample trees are provided for each traversal type. One question involves drawing a binary search tree from input data and finding its height.

Uploaded by

Kimpiz IT
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
100% found this document useful (1 vote)
55 views4 pages

Name: Student No.: Group:: Csc248 - Fundamentals of Data Structures Tree: Tutorial

This document contains a tutorial on trees with 4 questions. It discusses binary trees, their traversals (pre-order, in-order, post-order), heights, leaves, and ancestors. Examples of traversing sample trees are provided for each traversal type. One question involves drawing a binary search tree from input data and finding its height.

Uploaded by

Kimpiz IT
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/ 4

CSC248 - FUNDAMENTALS OF DATA STRUCTURES

TREE: TUTORIAL

NAME : MUHAMMAD AQIL BAZLI BIN OTHMAN

STUDENT NO. : 2018271462

GROUP : RCS1104C

QUESTION 1

Study the given Binary Tree and answer questions that follow:

(a) How many leaves are there in the above tree?

(b) What is the height of the tree?

(c) State the path from 8 to 12.

(d) State the nodes visited if these traversal methods are used:

(i) In-order traversal


(ii) Pre-order traversal
(iii) Post-order traversal

(a) 4
(b) 4
(c) 8 5 7 12
(d) (i) L RO RI = 9 5 1 7 2 12 |8| 4 3 11
(ii) RO L RI = 8| 5 9 7 1 12 2 | 4 11 3
CSC248 - FUNDAMENTALS OF DATA STRUCTURES
TREE: TUTORIAL

(iii) L RI RO = 9 1 2 12 7 5 |3 11 4| 8

QUESTION 2

According to the given tree, solve the following problems:

(a) Identify the height of the tree.

(b) List the ancestor of serial number 150.

(c) List the leaf node.

(d) Traverse the tree in post-order traversal.

(e) Traverse the tree in in-order traversal.

(a) 2
(b) 235 and 123
(c) 111 150 456
(d) L RI RO = 111 150 123 | 456 | 235
(e) L RO RI = 111 150 123 |235| 456
CSC248 - FUNDAMENTALS OF DATA STRUCTURES
TREE: TUTORIAL

QUESTION 3

Traverse the following tree using in-order, pre-order and post-order traversal.

In-order= 2 7 4 8 | 9 | 10 11 15
Pre-order= 9 | 4 2 7 8 | 11 10 15
Post-order= 7 2 8 4 | 10 15 11 | 9

QUESTION 4

Given the following input data:

61, 32, 77, 14, 27, 93, 69, 105, 81

Based on the input data above:

(a) Draw the input binary search tree.

(b) Traverse the tree in pre-order, in-order and post-order traversal.

(c) What is the height of the tree in (a).


CSC248 - FUNDAMENTALS OF DATA STRUCTURES
TREE: TUTORIAL

(a)

(b) pre-order=61 | 32 14 27 | 77 69 93 81 105


In-order= 14 27 32 | 61 | 69 77 81 93 105
Post-order= 27 14 32 | 69 81 105 93 77| 61
(c) 3

You might also like