SlideShare a Scribd company logo
1 of 13
Trees
Tree traversal
By : Dana Dia’a
Data structure and algorithms
Tree (ADT)
 What is a tree ?
 A set of nodes.
 Each node can have one or more children .
 Each node can have at most one parent.
Root
( no parent)
Leaves
( no child)
Node level
1
2
3
4
Binary tree
 In binary tree , each node has at most two children .
 In other word , it can have zero children ( empty ) , one or
two children but not more than two children .
 Examples of a binary trees :
binary search tree ( BSTree)
 Every node entry has a unique key ( keys are not the
same in the tree ) .
 All the keys in the left of a node are less than the key of
a node
 All the keys in the right of a node are greater than the
key of a node .
 Example of a BStree :
Left
Less than 8
Right
Greater than 8
A binary tree but NOT binary search
tree
Search a node
 A binary search tree provide an excellent structure for
searching a node .
 For example : find the node with value 6 .
 We compare: 6 is <or > 8( the root) ?
 6 is less than 8 so we go to the left of node .
 Then we compare : 6 is <or > 3 ?
 6 is greater than 3 so we go right to
The right of node .
 6 is found .
Tree traversal
 The process of visiting all nodes in a tree only
one time .
 Two classes :
 1 . Breadth – first traversal .
 2 . Depth –first traversal .
Breadth – first traversal
 We can go with two methods :
1. Visiting each node starting from the lowest level (
root ) and moving down level by level , visiting
each node from left to right . ( top – down – from
left – to right ) .
Output : 8 , 3 , 10 ,1 ,6 ,14 ,4 ,7
,13
Starts
Breadth – first traversal (cont.)
 The other method is :
1. Visiting each node starting from the highest level (
leaves ) and moving up level by level , visiting each
node from right to left . ( bottom – up – from right –
to left ) .
Starts
Output : 13 , 7 ,4 , 14 ,6 ,1 ,10 ,3 ,8
Depth – first traversal
 We have to consider three tasks in this type .
 V – visiting a node .
 L – traversing the left sub-tree if any .
 R – traversing the right sub-tree if any .
 There are six types of depth –first traversal , but
we will consider three of them :
 VLR ( Preorder )
 LVR ( Inorder )
 LRV ( Postorder)
VLR ( Preorder )
VLR
VLR VLR
VLRVLR VLR
VLR
VLR
VLR
Output : 8 ,3 ,1 ,6 ,4 ,7 ,10 ,14 ,13
Assuming that the
visit(v) is to output
the value
LVR ( Ineorder )
LVR
Output : 1 , 3 , 4 , 6 , 7 , 8 ,10 ,13 ,14
Assuming that the
visit() is to output
the valueLVR
LVR
LVR
LVR
LVR
LVR
LVRLVR
LRV ( Posteorder )
LRV
Output : 1 , 4 , 7 ,6 ,3 , 13 , 14 , 10 , 8
Assuming that the
visit() is to output
the value
LRV
LRV LRV
LRV
LRV
LRVLRVLRV

More Related Content

What's hot (20)

Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
BinarySearchTree-bddicken
BinarySearchTree-bddickenBinarySearchTree-bddicken
BinarySearchTree-bddicken
 
Merge sort
Merge sortMerge sort
Merge sort
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
 
Bfs new
Bfs newBfs new
Bfs new
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 
Echelon forms
Echelon formsEchelon forms
Echelon forms
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Data structure array
Data structure  arrayData structure  array
Data structure array
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 
Trees and graphs
Trees and graphsTrees and graphs
Trees and graphs
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
Threaded Binary Tree.pptx
Threaded Binary Tree.pptxThreaded Binary Tree.pptx
Threaded Binary Tree.pptx
 
Binary search tree in data structures
Binary search tree in  data structuresBinary search tree in  data structures
Binary search tree in data structures
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 
M ary-tree
M ary-treeM ary-tree
M ary-tree
 
Selection sort 1
Selection sort 1Selection sort 1
Selection sort 1
 

Viewers also liked

computer notes - Traversal of a binary tree
computer notes - Traversal of a binary treecomputer notes - Traversal of a binary tree
computer notes - Traversal of a binary treeecomputernotes
 
Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)raj upadhyay
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
sorting algorithm graphical method
sorting algorithm graphical method sorting algorithm graphical method
sorting algorithm graphical method Shantanu Mishra
 
Deloitte uk-cpo-survey-2014
Deloitte uk-cpo-survey-2014Deloitte uk-cpo-survey-2014
Deloitte uk-cpo-survey-2014Clive Gallery
 
Phrasal verbs vaughan
Phrasal verbs  vaughanPhrasal verbs  vaughan
Phrasal verbs vaughanlola macias
 
Selectivitat writing guide2
Selectivitat writing guide2Selectivitat writing guide2
Selectivitat writing guide2lola macias
 
KEEP IT SAFE FINAL IT Security A6 FINAL 2 (1)
KEEP IT SAFE FINAL IT Security A6 FINAL 2 (1)KEEP IT SAFE FINAL IT Security A6 FINAL 2 (1)
KEEP IT SAFE FINAL IT Security A6 FINAL 2 (1)Jenine Sanchez
 
ми всі майбутні таланти
ми всі майбутні талантими всі майбутні таланти
ми всі майбутні талантиJohn_Fikus
 
Fact Sheet_FederalAgency-Aug2016-FINAL
Fact Sheet_FederalAgency-Aug2016-FINALFact Sheet_FederalAgency-Aug2016-FINAL
Fact Sheet_FederalAgency-Aug2016-FINALAnn Warner
 
Khodiyar ceramics (i) pvt ltd corporate presentation
Khodiyar ceramics (i) pvt ltd corporate presentationKhodiyar ceramics (i) pvt ltd corporate presentation
Khodiyar ceramics (i) pvt ltd corporate presentationNakul Bhut
 
Question 1 x2
Question 1 x2Question 1 x2
Question 1 x2Kirsty98
 

Viewers also liked (20)

Binary tree
Binary  treeBinary  tree
Binary tree
 
Unit8 C
Unit8 CUnit8 C
Unit8 C
 
Tree
TreeTree
Tree
 
computer notes - Traversal of a binary tree
computer notes - Traversal of a binary treecomputer notes - Traversal of a binary tree
computer notes - Traversal of a binary tree
 
Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
 
4.2 bst
4.2 bst4.2 bst
4.2 bst
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Binary Search Algorithm
Binary Search Algorithm Binary Search Algorithm
Binary Search Algorithm
 
sorting algorithm graphical method
sorting algorithm graphical method sorting algorithm graphical method
sorting algorithm graphical method
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Deloitte uk-cpo-survey-2014
Deloitte uk-cpo-survey-2014Deloitte uk-cpo-survey-2014
Deloitte uk-cpo-survey-2014
 
Phrasal verbs vaughan
Phrasal verbs  vaughanPhrasal verbs  vaughan
Phrasal verbs vaughan
 
Selectivitat writing guide2
Selectivitat writing guide2Selectivitat writing guide2
Selectivitat writing guide2
 
KEEP IT SAFE FINAL IT Security A6 FINAL 2 (1)
KEEP IT SAFE FINAL IT Security A6 FINAL 2 (1)KEEP IT SAFE FINAL IT Security A6 FINAL 2 (1)
KEEP IT SAFE FINAL IT Security A6 FINAL 2 (1)
 
Proposal
ProposalProposal
Proposal
 
ми всі майбутні таланти
ми всі майбутні талантими всі майбутні таланти
ми всі майбутні таланти
 
Fact Sheet_FederalAgency-Aug2016-FINAL
Fact Sheet_FederalAgency-Aug2016-FINALFact Sheet_FederalAgency-Aug2016-FINAL
Fact Sheet_FederalAgency-Aug2016-FINAL
 
Khodiyar ceramics (i) pvt ltd corporate presentation
Khodiyar ceramics (i) pvt ltd corporate presentationKhodiyar ceramics (i) pvt ltd corporate presentation
Khodiyar ceramics (i) pvt ltd corporate presentation
 
Question 1 x2
Question 1 x2Question 1 x2
Question 1 x2
 

Similar to Tree data structure

Similar to Tree data structure (20)

trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Binary Tree - Algorithms
Binary Tree - Algorithms Binary Tree - Algorithms
Binary Tree - Algorithms
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
 
Tree data structure.pptx
Tree data structure.pptxTree data structure.pptx
Tree data structure.pptx
 
Biary search Tree.docx
Biary search Tree.docxBiary search Tree.docx
Biary search Tree.docx
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structure
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
4a searching-more
4a searching-more4a searching-more
4a searching-more
 
Binary trees
Binary treesBinary trees
Binary trees
 
Tree data structure
Tree data structureTree data structure
Tree data structure
 
Trees ayaz
Trees ayazTrees ayaz
Trees ayaz
 
VCE Unit 05.pptx
VCE Unit 05.pptxVCE Unit 05.pptx
VCE Unit 05.pptx
 
Tree Traversal
Tree TraversalTree Traversal
Tree Traversal
 
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
Trees
TreesTrees
Trees
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 

More from Dana dia

types of computer cases
types of computer cases types of computer cases
types of computer cases Dana dia
 
summarize system analysis and design ch2
summarize system analysis and design ch2 summarize system analysis and design ch2
summarize system analysis and design ch2 Dana dia
 
system analysis and design chapter 1 Kendall & Kendall
system analysis and design chapter 1 Kendall & Kendallsystem analysis and design chapter 1 Kendall & Kendall
system analysis and design chapter 1 Kendall & KendallDana dia
 
Os examples scheduling
Os examples schedulingOs examples scheduling
Os examples schedulingDana dia
 
Multicore system
Multicore systemMulticore system
Multicore systemDana dia
 
Multimedia
MultimediaMultimedia
MultimediaDana dia
 

More from Dana dia (6)

types of computer cases
types of computer cases types of computer cases
types of computer cases
 
summarize system analysis and design ch2
summarize system analysis and design ch2 summarize system analysis and design ch2
summarize system analysis and design ch2
 
system analysis and design chapter 1 Kendall & Kendall
system analysis and design chapter 1 Kendall & Kendallsystem analysis and design chapter 1 Kendall & Kendall
system analysis and design chapter 1 Kendall & Kendall
 
Os examples scheduling
Os examples schedulingOs examples scheduling
Os examples scheduling
 
Multicore system
Multicore systemMulticore system
Multicore system
 
Multimedia
MultimediaMultimedia
Multimedia
 

Recently uploaded

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 

Recently uploaded (20)

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

Tree data structure

  • 1. Trees Tree traversal By : Dana Dia’a Data structure and algorithms
  • 2. Tree (ADT)  What is a tree ?  A set of nodes.  Each node can have one or more children .  Each node can have at most one parent. Root ( no parent) Leaves ( no child) Node level 1 2 3 4
  • 3. Binary tree  In binary tree , each node has at most two children .  In other word , it can have zero children ( empty ) , one or two children but not more than two children .  Examples of a binary trees :
  • 4. binary search tree ( BSTree)  Every node entry has a unique key ( keys are not the same in the tree ) .  All the keys in the left of a node are less than the key of a node  All the keys in the right of a node are greater than the key of a node .  Example of a BStree : Left Less than 8 Right Greater than 8
  • 5. A binary tree but NOT binary search tree
  • 6. Search a node  A binary search tree provide an excellent structure for searching a node .  For example : find the node with value 6 .  We compare: 6 is <or > 8( the root) ?  6 is less than 8 so we go to the left of node .  Then we compare : 6 is <or > 3 ?  6 is greater than 3 so we go right to The right of node .  6 is found .
  • 7. Tree traversal  The process of visiting all nodes in a tree only one time .  Two classes :  1 . Breadth – first traversal .  2 . Depth –first traversal .
  • 8. Breadth – first traversal  We can go with two methods : 1. Visiting each node starting from the lowest level ( root ) and moving down level by level , visiting each node from left to right . ( top – down – from left – to right ) . Output : 8 , 3 , 10 ,1 ,6 ,14 ,4 ,7 ,13 Starts
  • 9. Breadth – first traversal (cont.)  The other method is : 1. Visiting each node starting from the highest level ( leaves ) and moving up level by level , visiting each node from right to left . ( bottom – up – from right – to left ) . Starts Output : 13 , 7 ,4 , 14 ,6 ,1 ,10 ,3 ,8
  • 10. Depth – first traversal  We have to consider three tasks in this type .  V – visiting a node .  L – traversing the left sub-tree if any .  R – traversing the right sub-tree if any .  There are six types of depth –first traversal , but we will consider three of them :  VLR ( Preorder )  LVR ( Inorder )  LRV ( Postorder)
  • 11. VLR ( Preorder ) VLR VLR VLR VLRVLR VLR VLR VLR VLR Output : 8 ,3 ,1 ,6 ,4 ,7 ,10 ,14 ,13 Assuming that the visit(v) is to output the value
  • 12. LVR ( Ineorder ) LVR Output : 1 , 3 , 4 , 6 , 7 , 8 ,10 ,13 ,14 Assuming that the visit() is to output the valueLVR LVR LVR LVR LVR LVR LVRLVR
  • 13. LRV ( Posteorder ) LRV Output : 1 , 4 , 7 ,6 ,3 , 13 , 14 , 10 , 8 Assuming that the visit() is to output the value LRV LRV LRV LRV LRV LRVLRVLRV