SlideShare a Scribd company logo
The Theory of Computation
‫االحتسابية‬ ‫النظرية‬
‫رقم‬ ‫المحاضرة‬
-
10
-
Binary Trees ‫الثنائية‬ ‫االشجار‬
‫إعداد‬
‫م‬
.
‫حميد‬ ‫حبيب‬ ‫وديان‬ ‫م‬
‫االساسية‬ ‫التربية‬ ‫كلية‬
/
‫الحاسبات‬ ‫قسم‬
Differences Between A Tree and A Binary Tree
The subtrees of a binary tree are ordered; those of a tree are not ordered.
• Are different when viewed as binary trees.
• Are the same when viewed as trees.
A
B
A
B
Data Structure for Binary Trees
• A node is represented by an object storing
• Element
• Parent node
• Left child node
• Right child node B
D
A
C E
Arithmetic Expression Tree
• Binary tree associated with an arithmetic expression
• internal nodes: operators
• external nodes: operands
• Example: arithmetic expression tree for the expression (2  (a - 1) + (3  b))
+


-
2
a 1
3 b
Decision Tree
• Binary tree associated with a decision process
• internal nodes: questions with yes/no answer
• external nodes: decisions
• Example: dining decision
Maximum Number of Nodes in a Binary Tree
• The maximum number of nodes on depth i of a binary
tree is 2i, i>=0.
• The maximum nubmer of nodes in a binary tree of height
k is 2k+1-1, k>=0.
Prove by induction.
1
2
2 1
0
-
 +

 k
k
i
i
Full Binary Tree
• A full binary tree of a given height k has 2k+1–1 nodes.
Height 3 full binary tree.
Labeling Nodes In A Full Binary Tree
• Label the nodes 1 through 2k+1 – 1.
• Label by levels from top to bottom.
• Within a level, label from left to right.
Node Number Properties
Parent of node i is node i / 2, unless i = 1.
Node 1 is the root and has no parent.
• Right child of node i is node
2i+1, unless 2i+1 > n, where n is
the number of nodes.
• If 2i+1 > n, node i has no right
child.
Complete Binary Trees
• A labeled binary tree containing the labels 1 to n with root 1,
branches leading to nodes labeled 2 and 3, branches from these
leading to 4, 5 and 6, 7, respectively, and so on.
• A binary tree with n nodes and level k is complete iff its nodes
correspond to the nodes numbered from 1 to n in the full binary tree
of level k.
1
2 3
7
5
9
4
8
6
Complete binary tree
1
2 3
7
5
11
4
10
6
9
8 15
14
13
12
Full binary tree of depth 3

More Related Content

PPT
Binary tree
PPT
358 33 powerpoint-slides_10-trees_chapter-10
PPTX
Tree all information about tree concept are available .
PDF
Module - 5_Trees.pdf
PPT
PPTX
Unit 3 trees
PDF
PPTX
binary tree.pptx
Binary tree
358 33 powerpoint-slides_10-trees_chapter-10
Tree all information about tree concept are available .
Module - 5_Trees.pdf
Unit 3 trees
binary tree.pptx

Similar to Lecture 10.pptx (20)

PPT
tree.ppt
PPTX
NON-LINEAR DATA STRUCTURE-TREES.pptx
PDF
Preparation Data Structures 10 trees
PPT
trees.ppt
PPT
Natural Trees for the future oil part 1.ppt
PPTX
Lecture 9: Binary tree basics
PPT
Lecture 5 tree.pptx
PPTX
Trees in Data Structure
PPTX
Complete_Binary_Trees_Presentation_.pptx
PPTX
Complete_Binary_Trees_Presentation__.pptx
PPTX
Complete_Binary_Trees_Presentation££.pptx
PPTX
DS-UNIT-4zjufrusefihfacbciauhfbaiuhc.pptx
PPTX
Introduction to Tree_Data Structure.pptx
PDF
Introduction to Binary Tree and Conersion of General tree to Binary Tree
PPTX
Unit – vi tree
PPTX
Unit 6 tree
PPTX
Lecture 8 data structures and algorithms
PPT
Introduction To Binary Search Trees .ppt
PPT
trees_data_structure_presentation_university of dallas.ppt
PPT
tree.ppt
NON-LINEAR DATA STRUCTURE-TREES.pptx
Preparation Data Structures 10 trees
trees.ppt
Natural Trees for the future oil part 1.ppt
Lecture 9: Binary tree basics
Lecture 5 tree.pptx
Trees in Data Structure
Complete_Binary_Trees_Presentation_.pptx
Complete_Binary_Trees_Presentation__.pptx
Complete_Binary_Trees_Presentation££.pptx
DS-UNIT-4zjufrusefihfacbciauhfbaiuhc.pptx
Introduction to Tree_Data Structure.pptx
Introduction to Binary Tree and Conersion of General tree to Binary Tree
Unit – vi tree
Unit 6 tree
Lecture 8 data structures and algorithms
Introduction To Binary Search Trees .ppt
trees_data_structure_presentation_university of dallas.ppt
Ad

More from SamiAAli44 (8)

PPTX
المحاضرة الاولى بور بوينت تعليم اساسي.pptx
PPTX
م.م عقيل ثامر (4).pptx
PPTX
م.م عقيل ثامر (9).pptx
PDF
virus-140717152102-phpapp02.pdf
PPT
________ ________1.ppt
PPTX
lce1 مترجمات.pptx
PPTX
محاضرات في مادة طرائق التدريس التخصصية (1).pptx
PPT
Computer-Networks--Network.ppt
المحاضرة الاولى بور بوينت تعليم اساسي.pptx
م.م عقيل ثامر (4).pptx
م.م عقيل ثامر (9).pptx
virus-140717152102-phpapp02.pdf
________ ________1.ppt
lce1 مترجمات.pptx
محاضرات في مادة طرائق التدريس التخصصية (1).pptx
Computer-Networks--Network.ppt
Ad

Recently uploaded (20)

PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Lesson notes of climatology university.
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Pre independence Education in Inndia.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Pharma ospi slides which help in ospi learning
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
master seminar digital applications in india
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Complications of Minimal Access Surgery at WLH
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
O5-L3 Freight Transport Ops (International) V1.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Microbial disease of the cardiovascular and lymphatic systems
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Insiders guide to clinical Medicine.pdf
Lesson notes of climatology university.
TR - Agricultural Crops Production NC III.pdf
human mycosis Human fungal infections are called human mycosis..pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Cell Structure & Organelles in detailed.
VCE English Exam - Section C Student Revision Booklet
Pre independence Education in Inndia.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharma ospi slides which help in ospi learning
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
master seminar digital applications in india
GDM (1) (1).pptx small presentation for students
Complications of Minimal Access Surgery at WLH
Module 4: Burden of Disease Tutorial Slides S2 2025

Lecture 10.pptx

  • 1. The Theory of Computation ‫االحتسابية‬ ‫النظرية‬ ‫رقم‬ ‫المحاضرة‬ - 10 - Binary Trees ‫الثنائية‬ ‫االشجار‬ ‫إعداد‬ ‫م‬ . ‫حميد‬ ‫حبيب‬ ‫وديان‬ ‫م‬ ‫االساسية‬ ‫التربية‬ ‫كلية‬ / ‫الحاسبات‬ ‫قسم‬
  • 2. Differences Between A Tree and A Binary Tree The subtrees of a binary tree are ordered; those of a tree are not ordered. • Are different when viewed as binary trees. • Are the same when viewed as trees. A B A B
  • 3. Data Structure for Binary Trees • A node is represented by an object storing • Element • Parent node • Left child node • Right child node B D A C E
  • 4. Arithmetic Expression Tree • Binary tree associated with an arithmetic expression • internal nodes: operators • external nodes: operands • Example: arithmetic expression tree for the expression (2  (a - 1) + (3  b)) +   - 2 a 1 3 b
  • 5. Decision Tree • Binary tree associated with a decision process • internal nodes: questions with yes/no answer • external nodes: decisions • Example: dining decision
  • 6. Maximum Number of Nodes in a Binary Tree • The maximum number of nodes on depth i of a binary tree is 2i, i>=0. • The maximum nubmer of nodes in a binary tree of height k is 2k+1-1, k>=0. Prove by induction. 1 2 2 1 0 -  +   k k i i
  • 7. Full Binary Tree • A full binary tree of a given height k has 2k+1–1 nodes. Height 3 full binary tree.
  • 8. Labeling Nodes In A Full Binary Tree • Label the nodes 1 through 2k+1 – 1. • Label by levels from top to bottom. • Within a level, label from left to right.
  • 9. Node Number Properties Parent of node i is node i / 2, unless i = 1. Node 1 is the root and has no parent. • Right child of node i is node 2i+1, unless 2i+1 > n, where n is the number of nodes. • If 2i+1 > n, node i has no right child.
  • 10. Complete Binary Trees • A labeled binary tree containing the labels 1 to n with root 1, branches leading to nodes labeled 2 and 3, branches from these leading to 4, 5 and 6, 7, respectively, and so on. • A binary tree with n nodes and level k is complete iff its nodes correspond to the nodes numbered from 1 to n in the full binary tree of level k. 1 2 3 7 5 9 4 8 6 Complete binary tree 1 2 3 7 5 11 4 10 6 9 8 15 14 13 12 Full binary tree of depth 3