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

SAS Day23 ITE048 Discrete Structure

This document is a student activity sheet for a course on Discrete Structures, focusing on binary trees. It outlines lesson objectives, key terminology, types of binary trees, and algorithms related to binary search trees. Additionally, it includes activities for students to apply their understanding of the concepts discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

SAS Day23 ITE048 Discrete Structure

This document is a student activity sheet for a course on Discrete Structures, focusing on binary trees. It outlines lesson objectives, key terminology, types of binary trees, and algorithms related to binary search trees. Additionally, it includes activities for students to apply their understanding of the concepts discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Course Code: ITE 048 Discrete Structure

Module #23 Student Activity Sheet

Name:_____________________________________________________________ Class number: ________


Section: ____________ Schedule: _____________________________________ Date: _______________
Lesson title: Binary Tree Materials:
SAS and Supplementary reading
Lesson Objectives:
At the end of the session, students should be able to: References:
1. Describe backtracking technique. • Johnsonbaugh, Richard (2018).
2. Know the algorithm of a depth-first search. Discrete Mathematics (8th Ed.)
3. Apply the DFS algorithm.
• www.tutorialspoint.com/discrete_
mathematics

A. LESSON PREVIEW/REVIEW

1) Introduction (2 mins)

On the previous lesson try to recall some of the important key notes of the lesson.

In this course, a very popular tree will be discussed and presented. There are many trees with
different algorithms. Binary tree is one of these trees. Before you continue with the lesson
proper, please consider Activity 1 and accomplish what is needed. So let’s get started.

B. MAIN LESSON

1) Activity 2: Content Notes (13 mins)

BINARY TREE

Binary trees are among the most important special types of rooted trees. Every vertex in a
binary tree has at most two children. Moreover, each child is designated as either a left child or
right child. When a binary tree is drawn, a left child is drawn to the left and right child is drawn to
the right.

A binary tree is a rooted tree in which each vertex has no children, one child or two children. If
a vertex has one child, that child is designated as either a left child or a right child.
A full binary tree is a binary tree in which each vertex has two or no children.

This document is the property of PHINMA EDUCATION 1


Course Code: ITE 048 Discrete Structure
Module #23 Student Activity Sheet

Name:_____________________________________________________________ Class number: ________


Section: ____________ Schedule: _____________________________________ Date: _______________

Basic Terminology:
1. Root: A binary tree has a unique node called the root of the tree.
2. Left Child: The node to the left of the root is called its left child.
3. Right Child: The node to the right of the root is called its right child.
4. Parent: A node having a left child or right child or both are called the parent of the nodes.
5. Siblings: Two nodes having the same parent are called siblings.
6. Leaf: A node with no children is called a leaf. The number of leaves in a binary tree can
vary from one (minimum) to half the number of vertices (maximum) in a tree.
7. Descendant: A node is called descendant of another node if it is the child of the node or
child of some other descendant of that node. All the nodes in the tree are descendants of
the root.
8. Left Subtree: The subtree whose root is the left child of some node is called the left
subtree of that node.
Example: For the tree as shown in fig:
• Which node is the root?
• Which nodes are leaves?
• Name the parent node of each node

Solution: (i) The node A is the root node.


(ii) The nodes G, H, I, L, M, N, O
are leaves.
(iii) Nodes Parent
B, C A
D, E B
F C
G, H D
I, J E
K F
L, M J
N, O K

Right Subtree: The subtree whose root is the right child of some node is called the right
subtree of that node.
Level of a Node: The level of a node is its distance from the root. The level of root is defined
as zero. The level of all other nodes is one more than its parent node. The maximum number
of nodes at any level N is 2N.

This document is the property of PHINMA EDUCATION 2


Course Code: ITE 048 Discrete Structure
Module #23 Student Activity Sheet

Name:_____________________________________________________________ Class number: ________


Section: ____________ Schedule: _____________________________________ Date: _______________

Depth or Height of a tree: The depth or height of a tree is defined as the maximum number
of nodes in a branch of a tree. This is more than the maximum level of the tree, i.e., the depth
of root is one. The maximum number of nodes in a binary tree of depth d is 2d-1, where d ≥1.
External Nodes: The nodes which have no children are called external nodes or terminal
nodes.
Internal Nodes: The nodes which have one or more than one children are called internal
nodes or non-terminal nodes.
Binary Expression Trees:
An algebraic expression can be conveniently expressed by its expression tree. An expression
having binary operators can be decomposed into
<left operand or expression> (operator) <right operand or expression>
Depending upon precedence of evaluation.

The expression tree is a binary tree whose root contains the


operator and whose left subtree contains the left expression,
and right subtree contains the right expression.

Example: Construct the binary expression tree for the


expression (a+b)*(d/c)
Solution: The binary expression tree for the expression
(a+b)*(d/c) is shown in fig:

Complete Binary Tree: Complete binary tree is a binary tree


if it is all levels, except possibly the last, have the maximum
number of possible nodes as for left as possible. The depth of
the complete binary tree having n nodes is log2 n+1.
Example: The tree shown in fig is a complete binary
tree.

Full Binary Tree: Full binary tree is a binary tree in which


all the leaves are on the same level and every non-leaf
node has two children.

This document is the property of PHINMA EDUCATION 3


Course Code: ITE 048 Discrete Structure
Module #23 Student Activity Sheet

Name:_____________________________________________________________ Class number: ________


Section: ____________ Schedule: _____________________________________ Date: _______________

Differentiate between General Tree and Binary Tree


General Tree Binary Tree
1. There is no such tree having zero nodes 1. There may be an empty binary tree.
or an empty general tree.
2. If some node has a child, then there is no 2. If some node has a child, then it is distinguished
such distinction. as a left child or a right child.
3. The trees shown in fig are the same, 3. The trees shown in fig are distinct, when we
when we consider them as general trees. consider them as binary trees, because in (4) is the
right child of 2 while in (ii) 4 is a left child of 2.

BINARY SEARCH TREE

A binary search tree is a binary tree in which data are


associated with the vertices. The data are arranged so that,
for each vertex in T, each data item in the left sub-tree of v
is less than the data item in v, and each data item in the
right sub-tree of v is greater than the data item in v.

In binary search tree:


• All identifiers in the left sub-tree are less
than the identifier in the root.
• All identifiers in the right sub-tree are
greater than the identifier in the root.
• The left and the right sub-trees are also binary search
trees.

This document is the property of PHINMA EDUCATION 4


Course Code: ITE 048 Discrete Structure
Module #23 Student Activity Sheet

Name:_____________________________________________________________ Class number: ________


Section: ____________ Schedule: _____________________________________ Date: _______________

Binary search trees are useful in locating data. In general, there will be many ways to place

BST Algorithm: Insertion


1. If the tree is empty, then insert the new item in the
tree’s root node
2. If the root’s key matches the new item’s
key then skip insertion.
3. If the new item’s key is smaller than the
root’s key, then insert the new item in the
root’s left sub-tree. Otherwise insert the
new item in the root’s right sub- tree

Skill-building Activities Score : _______

I. Instruction: Draw the unique binary tree for the given Inorder and Postorder traversal
is given as follows:

Inorder Postorder Draw here:


4 12
6 10
10 8
12 6
8 4
2 2
1 13
5 11
7 9
11 7
13 5
9 3
3 1

This document is the property of PHINMA EDUCATION 5


Course Code: ITE 048 Discrete Structure
Module #23 Student Activity Sheet

Name:_____________________________________________________________ Class number: ________


Section: ____________ Schedule: _____________________________________ Date: _______________

Check for Understanding

I. Instruction: Convert the following tree as shown in fig into a binary tree.

Draw here:

This document is the property of PHINMA EDUCATION 6


Course Code: ITE 048 Discrete Structure
Module #23 Student Activity Sheet

Name:_____________________________________________________________ Class number: ________


Section: ____________ Schedule: _____________________________________ Date: _______________

C. LESSON WRAP-UP

FAQs
1. What are the different types of trees aside from binary tree?
ANSWER:
• B-tree • Self-balancing tree
• Binary search tree • Splay tree
• AA tree • Heap, Binary heap, Binomial heap,
Fibonacci heap
• AVL tree • tree, R* tree, R+ tree, Hilbert R-tree
• Red–black tree • Trie, Hash tree

4) Activity 5: Thinking about Learning (5 mins)

Mark the place in the work tracker which is simply a visual to help you track how much
work you have accomplished and how much work there is left to do. This tracker will be
part of your activity sheet.

To develop habits on thinking about learning, answer the questions below about
your learningexperience.

1. How was the module able to help you learn?

2. What did you realize about the topic?

This document is the property of PHINMA EDUCATION 7


Course Code: ITE 048 Discrete Structure
Module #23 Student Activity Sheet

Name:_____________________________________________________________ Class number: ________


Section: ____________ Schedule: _____________________________________ Date: _______________

KEY CORRECTIONS
Answer Skill Building Activities

Solution: We know that the root of the binary tree is the last node in
the postorder traversal. Hence, one in the root node.

Now, check the inorder traversal, we know that root is at the center,
hence all the nodes that are left to the root node in inorder traversal
are the nodes of left subtree and, all that are right to the root node
are the nodes of the right subtree.

Now, visit the next node from back in postorder traversal and
check its position in inorder traversal, if it is on the left of root then
draw it as left child and if it is on the right, then draw it as the right
child.

Repeat the above process for each new node, and we obtain the
binary tree as shown in fig:

This document is the property of PHINMA EDUCATION 8

You might also like