SlideShare a Scribd company logo
Chapter 6

Introduction to Trees
Objectives
Upon completion you will be able to:
• Understand and use basic tree terminology and concepts
• Recognize and define the basic attributes of a binary tree
• Process trees using depth-first and breadth-first traversals
• Parse expressions using a binary tree
• Design and implement Huffman trees
• Understand the basic use and processing of general trees
Data Structures: A Pseudocode Approach with C

1
6-1 Basic Tree Concepts
We begin the Chapter with a discussion of the terminology used
with trees. Once the terminology is understood, we discuss three
user-oriented tree representations: general trees, indented parts
lists, and parenthetical trees.

• Terminology
• User Representation

Data Structures: A Pseudocode Approach with C

2
Data Structures: A Pseudocode Approach with C

3
Data Structures: A Pseudocode Approach with C

4
Data Structures: A Pseudocode Approach with C

5
Data Structures: A Pseudocode Approach with C

6
Data Structures: A Pseudocode Approach with C

7
Data Structures: A Pseudocode Approach with C

8
6-2 Binary Trees
A binary tree can have no more than two descendents. In this
section we discuss the properties of binary trees, four different
binary tree traversals, and two applications, expression trees and
Huffman Code.

• Properties
• Binary Tree Traversals
• Expression Trees
• Huffman Code

Data Structures: A Pseudocode Approach with C

9
Data Structures: A Pseudocode Approach with C

10
Data Structures: A Pseudocode Approach with C

11
Data Structures: A Pseudocode Approach with C

12
Data Structures: A Pseudocode Approach with C

13
Data Structures: A Pseudocode Approach with C

14
Data Structures: A Pseudocode Approach with C

15
Data Structures: A Pseudocode Approach with C

16
Data Structures: A Pseudocode Approach with C

17
Data Structures: A Pseudocode Approach with C

18
Data Structures: A Pseudocode Approach with C

19
Data Structures: A Pseudocode Approach with C

20
Data Structures: A Pseudocode Approach with C

21
Data Structures: A Pseudocode Approach with C

22
Data Structures: A Pseudocode Approach with C

23
Data Structures: A Pseudocode Approach with C

24
Data Structures: A Pseudocode Approach with C

25
Data Structures: A Pseudocode Approach with C

26
Data Structures: A Pseudocode Approach with C

27
Data Structures: A Pseudocode Approach with C

28
Data Structures: A Pseudocode Approach with C

29
Data Structures: A Pseudocode Approach with C

30
Data Structures: A Pseudocode Approach with C

31
Data Structures: A Pseudocode Approach with C

32
Data Structures: A Pseudocode Approach with C

33
Data Structures: A Pseudocode Approach with C

34
6-3 General Trees
A general tree can have an unlimited number of descendents. We
discuss three topics in this section: general tree insertions,
deletions, and converting a general tree to a binary tree.

• Insertions into General Trees
• General Tree Deletions
• Changing a General Tree to a Binary Tree

Data Structures: A Pseudocode Approach with C

35
Data Structures: A Pseudocode Approach with C

36
Data Structures: A Pseudocode Approach with C

37
Data Structures: A Pseudocode Approach with C

38
Data Structures: A Pseudocode Approach with C

39
Data Structures: A Pseudocode Approach with C

40
Data Structures: A Pseudocode Approach with C

41
Data Structures: A Pseudocode Approach with C

42
Data Structures: A Pseudocode Approach with C

43
Data Structures: A Pseudocode Approach with C

44

More Related Content

Similar to Introduction to trees

Basic concepts
Basic conceptsBasic concepts
Basic concepts
Huma Ayub
 
Basic.ppt
Basic.pptBasic.ppt
Basic.ppt
VandanaBharti21
 
B.Tech 2nd Year CSE & CSIT AICTE Model Curriculum 2019-20.pdf
B.Tech 2nd Year CSE & CSIT AICTE Model Curriculum 2019-20.pdfB.Tech 2nd Year CSE & CSIT AICTE Model Curriculum 2019-20.pdf
B.Tech 2nd Year CSE & CSIT AICTE Model Curriculum 2019-20.pdf
Anita Pal
 
SE-IT DSA THEORY SYLLABUS
SE-IT DSA THEORY SYLLABUSSE-IT DSA THEORY SYLLABUS
SE-IT DSA THEORY SYLLABUS
nikshaikh786
 
Concepts, use cases and principles to build big data systems (1)
Concepts, use cases and principles to build big data systems (1)Concepts, use cases and principles to build big data systems (1)
Concepts, use cases and principles to build big data systems (1)
Trieu Nguyen
 
Data Structures and Algorithm - Week 4 - Trees, Binary Trees
Data Structures and Algorithm - Week 4 - Trees, Binary TreesData Structures and Algorithm - Week 4 - Trees, Binary Trees
Data Structures and Algorithm - Week 4 - Trees, Binary Trees
Ferdin Joe John Joseph PhD
 
Acc 564 quiz 4 – strayer new
Acc 564 quiz 4 – strayer newAcc 564 quiz 4 – strayer new
Acc 564 quiz 4 – strayer new
ninfaames
 
computer system architecture
computer system architecturecomputer system architecture
computer system architecture
dileesh E D
 
Chapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdfChapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdf
TamiratDejene1
 
Chapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdfChapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdf
TamiratDejene1
 
ICT_PracticeWorks[1].pdf
ICT_PracticeWorks[1].pdfICT_PracticeWorks[1].pdf
ICT_PracticeWorks[1].pdf
ssuserade1a1
 
cprogramming questions for practice end term
cprogramming questions for practice end termcprogramming questions for practice end term
cprogramming questions for practice end term
Sheelendra3
 
ESWC 2011 BLOOMS+
ESWC 2011 BLOOMS+ ESWC 2011 BLOOMS+
ESWC 2011 BLOOMS+
Prateek Jain
 
Conclusions: Summary and Outlook
Conclusions: Summary and OutlookConclusions: Summary and Outlook
Conclusions: Summary and Outlook
Nikolaos Konstantinou
 
Knowledge graphs for knowing more and knowing for sure
Knowledge graphs for knowing more and knowing for sureKnowledge graphs for knowing more and knowing for sure
Knowledge graphs for knowing more and knowing for sure
Steffen Staab
 
big data presentation to upload.pptx
big data presentation to upload.pptxbig data presentation to upload.pptx
big data presentation to upload.pptx
Alkalimatayiba
 
Dbms
DbmsDbms
Jumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema DesignJumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema Design
MongoDB
 
Graph Data Modeling Best Practices(Eric_Monk).pptx
Graph Data Modeling Best Practices(Eric_Monk).pptxGraph Data Modeling Best Practices(Eric_Monk).pptx
Graph Data Modeling Best Practices(Eric_Monk).pptx
Neo4j
 

Similar to Introduction to trees (20)

Basic concepts
Basic conceptsBasic concepts
Basic concepts
 
Basic.ppt
Basic.pptBasic.ppt
Basic.ppt
 
B.Tech 2nd Year CSE & CSIT AICTE Model Curriculum 2019-20.pdf
B.Tech 2nd Year CSE & CSIT AICTE Model Curriculum 2019-20.pdfB.Tech 2nd Year CSE & CSIT AICTE Model Curriculum 2019-20.pdf
B.Tech 2nd Year CSE & CSIT AICTE Model Curriculum 2019-20.pdf
 
SE-IT DSA THEORY SYLLABUS
SE-IT DSA THEORY SYLLABUSSE-IT DSA THEORY SYLLABUS
SE-IT DSA THEORY SYLLABUS
 
Concepts, use cases and principles to build big data systems (1)
Concepts, use cases and principles to build big data systems (1)Concepts, use cases and principles to build big data systems (1)
Concepts, use cases and principles to build big data systems (1)
 
Data Structures and Algorithm - Week 4 - Trees, Binary Trees
Data Structures and Algorithm - Week 4 - Trees, Binary TreesData Structures and Algorithm - Week 4 - Trees, Binary Trees
Data Structures and Algorithm - Week 4 - Trees, Binary Trees
 
Acc 564 quiz 4 – strayer new
Acc 564 quiz 4 – strayer newAcc 564 quiz 4 – strayer new
Acc 564 quiz 4 – strayer new
 
computer system architecture
computer system architecturecomputer system architecture
computer system architecture
 
Chapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdfChapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdf
 
Chapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdfChapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdf
 
ICT_PracticeWorks[1].pdf
ICT_PracticeWorks[1].pdfICT_PracticeWorks[1].pdf
ICT_PracticeWorks[1].pdf
 
cprogramming questions for practice end term
cprogramming questions for practice end termcprogramming questions for practice end term
cprogramming questions for practice end term
 
ESWC 2011 BLOOMS+
ESWC 2011 BLOOMS+ ESWC 2011 BLOOMS+
ESWC 2011 BLOOMS+
 
Conclusions: Summary and Outlook
Conclusions: Summary and OutlookConclusions: Summary and Outlook
Conclusions: Summary and Outlook
 
Knowledge graphs for knowing more and knowing for sure
Knowledge graphs for knowing more and knowing for sureKnowledge graphs for knowing more and knowing for sure
Knowledge graphs for knowing more and knowing for sure
 
Week 1
Week 1Week 1
Week 1
 
big data presentation to upload.pptx
big data presentation to upload.pptxbig data presentation to upload.pptx
big data presentation to upload.pptx
 
Dbms
DbmsDbms
Dbms
 
Jumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema DesignJumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema Design
 
Graph Data Modeling Best Practices(Eric_Monk).pptx
Graph Data Modeling Best Practices(Eric_Monk).pptxGraph Data Modeling Best Practices(Eric_Monk).pptx
Graph Data Modeling Best Practices(Eric_Monk).pptx
 

More from priya_trehan

Security Mechanisms
Security MechanismsSecurity Mechanisms
Security Mechanismspriya_trehan
 
Types of E commerce & Payment Models
Types of E commerce & Payment ModelsTypes of E commerce & Payment Models
Types of E commerce & Payment Modelspriya_trehan
 
Friction as a necessary evil
Friction as a necessary evilFriction as a necessary evil
Friction as a necessary evilpriya_trehan
 
Silent sound technology
Silent sound technologySilent sound technology
Silent sound technologypriya_trehan
 

More from priya_trehan (14)

Security Mechanisms
Security MechanismsSecurity Mechanisms
Security Mechanisms
 
Wordpress
WordpressWordpress
Wordpress
 
Types of E commerce & Payment Models
Types of E commerce & Payment ModelsTypes of E commerce & Payment Models
Types of E commerce & Payment Models
 
Friction as a necessary evil
Friction as a necessary evilFriction as a necessary evil
Friction as a necessary evil
 
File handling
File handlingFile handling
File handling
 
Datapreprocessing
DatapreprocessingDatapreprocessing
Datapreprocessing
 
Johari window
Johari windowJohari window
Johari window
 
Input output
Input outputInput output
Input output
 
Silent sound technology
Silent sound technologySilent sound technology
Silent sound technology
 
Packages
PackagesPackages
Packages
 
Protocols
ProtocolsProtocols
Protocols
 
Kiosk
KioskKiosk
Kiosk
 
Photoshop
PhotoshopPhotoshop
Photoshop
 
Art of listening
Art of listeningArt of listening
Art of listening
 

Recently uploaded

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 

Recently uploaded (20)

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 

Introduction to trees