SlideShare a Scribd company logo
Name: Panchal Dhrumil Indravadan
Subject: Data Structure
Branch: Computer Engineering (B.E.)
Semester: Third Sem
Year: 2018-19
Tree Traversal
 Binary Tree Traversal
 Preorder
 Inorder
 Postorder
 Example
 The most common operations performed on tree
structure is that of traversal. This is a procedure by
which each node in the tree is processed exactly
once in a systematic manner.
 There are three ways of traversing a binary tree.
 1. Preorder Traversal
 2. Inorder Traversal
 3. Postorder Traversal
 Preorder traversal : A B C D E F G
 Inorder traversal : C B A E F D G
 Postorder traversal : C B F E G D A
 Converse Preorder traversal : A D G E F B C
 Converse Inorder traversal : G D F E A B C
 Converse Postorder traversal : G F E D C B A
A
B
C
D
E
F
G
 Preorder traversal of a binary tree is defined as follow
 Process the root node
 Traverse the left subtree in preorder
 Traverse the right subtree in preorder
 If particular subtree is empty (i.e., node has no left or
right descendant) the traversal is performed by doing
nothing, In other words, a null subtree is considered to
be fully traversed when it is encountered.
 The preorder traversal of a tree is given by
 A B C D E F G
 The Inorder traversal of a binary tree is given by
following steps,
Traverse the left subtree in Inorder
Process the root node
Traverse the right subtree in Inorder
• The Inorder traversal of a tree is given by
• C B A E F D G
 The postorder traversal is given by
Traverse the left subtree in postorder
Traverse the right subtree in postorder
Process the root node
 The Postorder traversal of a tree is given by
 C B F E G D A
 If we interchange left and right words in the
preceding definitions, we obtain three new traversal
orders which are called
Converse Preorder (A D G E F B C)
Converse Inorder (G D F E A B C)
Converse Postorder (G F E D C B A)
 Given a binary tree whose root node address is
given by pointer variable root and whose node
structure is same as described below. This
procedure traverses the tree in preorder, in a
recursive manner.
ROOT LPTR RPTR
 void preorder (root)
 {
 if (root==NULL)
 return;
 printf (“ %dn ”, root->info);
 preorder ( root-> left);
 preorder ( root-> right);
 }
 Given a binary tree whose root node address is
given by pointer variable “root” and whose node
structure is same as described below. This
procedure traverses the tree in inorder, in a
recursive manner.
LPTR ROOT RPTR
 void inorder (root->left)
 {
 if (root==NULL)
 return;
 inorder ( root);
 printf (“ %dn ”, root->info);
 inorder ( root-> right);
 }
 Given a binary tree whose root node address is
given by pointer variable “root” and whose node
structure is same as described below. This
procedure traverses the tree in postorder, in a
recursive manner.
LPTR RPTR ROOT
 void postorder (root->left)
 {
 if (root==NULL)
 return;
 postorder (root-> right);
 postorder (root);
 printf (“ %dn ”, root->info);
 }
 Inorder: 2 1 4 5 3
 Preorder: 1 2 3 4 5
 Post order: 2 5 4 3 1
1
2 3
4
5
 Inspiration from Prof. Keyur Suthar and Prof.
Rashmin Prajapati
 Notes of DS
 Textbook of DS
 Image from Google images
 Some my own knowledge
#include<stdio.h>
int main()
{
printf(“Thank You”);
return 0;
}
Ad

More Related Content

What's hot (20)

Linked list
Linked listLinked list
Linked list
KalaivaniKS1
 
Linked list
Linked listLinked list
Linked list
akshat360
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSA
junnubabu
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
Hossain Md Shakhawat
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
single linked list
single linked listsingle linked list
single linked list
Sathasivam Rangasamy
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
Masud Parvaze
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
Jeanie Arnoco
 
Presentation on queue
Presentation on queuePresentation on queue
Presentation on queue
Rojan Pariyar
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
Dharita Chokshi
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
Poojith Chowdhary
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
karthikeyanC40
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
ghhgj jhgh
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
Balwant Gorad
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
Prateek Parimal
 
Queue ppt
Queue pptQueue ppt
Queue ppt
SouravKumar328
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSA
junnubabu
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
Jeanie Arnoco
 
Presentation on queue
Presentation on queuePresentation on queue
Presentation on queue
Rojan Pariyar
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
Dharita Chokshi
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
ghhgj jhgh
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
Balwant Gorad
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 

Similar to Binary Tree Traversal (20)

Lect 22 Zaheer Abbas
Lect 22 Zaheer AbbasLect 22 Zaheer Abbas
Lect 22 Zaheer Abbas
Information Technology Center
 
Trees
TreesTrees
Trees
9590133127
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
bca data structure
bca data structurebca data structure
bca data structure
shini
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
Muhazzab Chouhadry
 
DS MCQS.pptx
DS MCQS.pptxDS MCQS.pptx
DS MCQS.pptx
BoomijaIT
 
Algorithm and Data Structure - Binary Trees
Algorithm and Data Structure - Binary TreesAlgorithm and Data Structure - Binary Trees
Algorithm and Data Structure - Binary Trees
donotreply20
 
Data structure
Data structureData structure
Data structure
Mariam Saeed
 
Trees unit 3
Trees unit 3Trees unit 3
Trees unit 3
praveena p
 
Trees - Non Linear Data Structure
Trees - Non Linear Data StructureTrees - Non Linear Data Structure
Trees - Non Linear Data Structure
Priyanka Rana
 
Trees
TreesTrees
Trees
Avila Rebello
 
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxTREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
asimshahzad8611
 
Tree.ppt......................................
Tree.ppt......................................Tree.ppt......................................
Tree.ppt......................................
XEON14
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
Admissions in india 2015
Admissions in india 2015Admissions in india 2015
Admissions in india 2015
Edhole.com
 
Lecture 8 tree traversal
Lecture 8 tree traversalLecture 8 tree traversal
Lecture 8 tree traversal
Abirami A
 
Lecture 6 tree traversal
Lecture 6 tree traversalLecture 6 tree traversal
Lecture 6 tree traversal
Abirami A
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
almario1988
 
Unit8 C
Unit8 CUnit8 C
Unit8 C
arnold 7490
 
Weak 13 Trees, BST update.pptxhjjujjjhhhy
Weak 13 Trees, BST update.pptxhjjujjjhhhyWeak 13 Trees, BST update.pptxhjjujjjhhhy
Weak 13 Trees, BST update.pptxhjjujjjhhhy
baloch4551701
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
bca data structure
bca data structurebca data structure
bca data structure
shini
 
DS MCQS.pptx
DS MCQS.pptxDS MCQS.pptx
DS MCQS.pptx
BoomijaIT
 
Algorithm and Data Structure - Binary Trees
Algorithm and Data Structure - Binary TreesAlgorithm and Data Structure - Binary Trees
Algorithm and Data Structure - Binary Trees
donotreply20
 
Trees - Non Linear Data Structure
Trees - Non Linear Data StructureTrees - Non Linear Data Structure
Trees - Non Linear Data Structure
Priyanka Rana
 
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxTREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
asimshahzad8611
 
Tree.ppt......................................
Tree.ppt......................................Tree.ppt......................................
Tree.ppt......................................
XEON14
 
Admissions in india 2015
Admissions in india 2015Admissions in india 2015
Admissions in india 2015
Edhole.com
 
Lecture 8 tree traversal
Lecture 8 tree traversalLecture 8 tree traversal
Lecture 8 tree traversal
Abirami A
 
Lecture 6 tree traversal
Lecture 6 tree traversalLecture 6 tree traversal
Lecture 6 tree traversal
Abirami A
 
Weak 13 Trees, BST update.pptxhjjujjjhhhy
Weak 13 Trees, BST update.pptxhjjujjjhhhyWeak 13 Trees, BST update.pptxhjjujjjhhhy
Weak 13 Trees, BST update.pptxhjjujjjhhhy
baloch4551701
 
Ad

More from Dhrumil Panchal (20)

YouTube Cryptocurrency Scam
YouTube Cryptocurrency ScamYouTube Cryptocurrency Scam
YouTube Cryptocurrency Scam
Dhrumil Panchal
 
This and Static Keyword
This and Static KeywordThis and Static Keyword
This and Static Keyword
Dhrumil Panchal
 
Servlet and Servlet Life Cycle
Servlet and Servlet Life CycleServlet and Servlet Life Cycle
Servlet and Servlet Life Cycle
Dhrumil Panchal
 
Properties and Indexers
Properties and IndexersProperties and Indexers
Properties and Indexers
Dhrumil Panchal
 
Chomsky Normal Form
Chomsky Normal FormChomsky Normal Form
Chomsky Normal Form
Dhrumil Panchal
 
IEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and ServicesIEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and Services
Dhrumil Panchal
 
Key roles for successful analytic project in Data Mining
Key roles for successful analytic project in Data MiningKey roles for successful analytic project in Data Mining
Key roles for successful analytic project in Data Mining
Dhrumil Panchal
 
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dhrumil Panchal
 
Different Software Testing Types and CMM Standard
Different Software Testing Types and CMM StandardDifferent Software Testing Types and CMM Standard
Different Software Testing Types and CMM Standard
Dhrumil Panchal
 
Web Design Issues
Web Design IssuesWeb Design Issues
Web Design Issues
Dhrumil Panchal
 
Toy Interpreter
Toy InterpreterToy Interpreter
Toy Interpreter
Dhrumil Panchal
 
Traditional Problems Associated with Computer Crime
Traditional Problems Associated with Computer CrimeTraditional Problems Associated with Computer Crime
Traditional Problems Associated with Computer Crime
Dhrumil Panchal
 
Breadth First Search (BFS)
Breadth First Search (BFS)Breadth First Search (BFS)
Breadth First Search (BFS)
Dhrumil Panchal
 
Timing Diagram of MVI Instruction of 8085 Microprocessor
Timing Diagram of MVI Instruction of 8085 MicroprocessorTiming Diagram of MVI Instruction of 8085 Microprocessor
Timing Diagram of MVI Instruction of 8085 Microprocessor
Dhrumil Panchal
 
File Management – File Concept, access methods, File types and File Operation
File Management – File Concept, access methods,  File types and File OperationFile Management – File Concept, access methods,  File types and File Operation
File Management – File Concept, access methods, File types and File Operation
Dhrumil Panchal
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
Dhrumil Panchal
 
Types of Instruction Format
Types of Instruction FormatTypes of Instruction Format
Types of Instruction Format
Dhrumil Panchal
 
Types of Cables(Guided Media for Transmisson)
Types of Cables(Guided Media for Transmisson)Types of Cables(Guided Media for Transmisson)
Types of Cables(Guided Media for Transmisson)
Dhrumil Panchal
 
Global Service for Mobile Communication
Global Service for Mobile CommunicationGlobal Service for Mobile Communication
Global Service for Mobile Communication
Dhrumil Panchal
 
Denial of Service Attack
Denial of Service AttackDenial of Service Attack
Denial of Service Attack
Dhrumil Panchal
 
YouTube Cryptocurrency Scam
YouTube Cryptocurrency ScamYouTube Cryptocurrency Scam
YouTube Cryptocurrency Scam
Dhrumil Panchal
 
Servlet and Servlet Life Cycle
Servlet and Servlet Life CycleServlet and Servlet Life Cycle
Servlet and Servlet Life Cycle
Dhrumil Panchal
 
IEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and ServicesIEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and Services
Dhrumil Panchal
 
Key roles for successful analytic project in Data Mining
Key roles for successful analytic project in Data MiningKey roles for successful analytic project in Data Mining
Key roles for successful analytic project in Data Mining
Dhrumil Panchal
 
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dhrumil Panchal
 
Different Software Testing Types and CMM Standard
Different Software Testing Types and CMM StandardDifferent Software Testing Types and CMM Standard
Different Software Testing Types and CMM Standard
Dhrumil Panchal
 
Traditional Problems Associated with Computer Crime
Traditional Problems Associated with Computer CrimeTraditional Problems Associated with Computer Crime
Traditional Problems Associated with Computer Crime
Dhrumil Panchal
 
Breadth First Search (BFS)
Breadth First Search (BFS)Breadth First Search (BFS)
Breadth First Search (BFS)
Dhrumil Panchal
 
Timing Diagram of MVI Instruction of 8085 Microprocessor
Timing Diagram of MVI Instruction of 8085 MicroprocessorTiming Diagram of MVI Instruction of 8085 Microprocessor
Timing Diagram of MVI Instruction of 8085 Microprocessor
Dhrumil Panchal
 
File Management – File Concept, access methods, File types and File Operation
File Management – File Concept, access methods,  File types and File OperationFile Management – File Concept, access methods,  File types and File Operation
File Management – File Concept, access methods, File types and File Operation
Dhrumil Panchal
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
Dhrumil Panchal
 
Types of Instruction Format
Types of Instruction FormatTypes of Instruction Format
Types of Instruction Format
Dhrumil Panchal
 
Types of Cables(Guided Media for Transmisson)
Types of Cables(Guided Media for Transmisson)Types of Cables(Guided Media for Transmisson)
Types of Cables(Guided Media for Transmisson)
Dhrumil Panchal
 
Global Service for Mobile Communication
Global Service for Mobile CommunicationGlobal Service for Mobile Communication
Global Service for Mobile Communication
Dhrumil Panchal
 
Denial of Service Attack
Denial of Service AttackDenial of Service Attack
Denial of Service Attack
Dhrumil Panchal
 
Ad

Recently uploaded (20)

Fundamentals of Data Analysis, its types, tools, algorithms
Fundamentals of Data Analysis, its types, tools, algorithmsFundamentals of Data Analysis, its types, tools, algorithms
Fundamentals of Data Analysis, its types, tools, algorithms
priyaiyerkbcsc
 
RAG Chatbot using AWS Bedrock and Streamlit Framework
RAG Chatbot using AWS Bedrock and Streamlit FrameworkRAG Chatbot using AWS Bedrock and Streamlit Framework
RAG Chatbot using AWS Bedrock and Streamlit Framework
apanneer
 
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdfTOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
NhiV747372
 
Mining a Global Trade Process with Data Science - Microsoft
Mining a Global Trade Process with Data Science - MicrosoftMining a Global Trade Process with Data Science - Microsoft
Mining a Global Trade Process with Data Science - Microsoft
Process mining Evangelist
 
50_questions_full.pptxdddddddddddddddddd
50_questions_full.pptxdddddddddddddddddd50_questions_full.pptxdddddddddddddddddd
50_questions_full.pptxdddddddddddddddddd
emir73065
 
Introduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdfIntroduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdf
AbdurahmanAbd
 
Lagos School of Programming Final Project Updated.pdf
Lagos School of Programming Final Project Updated.pdfLagos School of Programming Final Project Updated.pdf
Lagos School of Programming Final Project Updated.pdf
benuju2016
 
indonesia-gen-z-report-2024 Gen Z (born between 1997 and 2012) is currently t...
indonesia-gen-z-report-2024 Gen Z (born between 1997 and 2012) is currently t...indonesia-gen-z-report-2024 Gen Z (born between 1997 and 2012) is currently t...
indonesia-gen-z-report-2024 Gen Z (born between 1997 and 2012) is currently t...
disnakertransjabarda
 
What is ETL? Difference between ETL and ELT?.pdf
What is ETL? Difference between ETL and ELT?.pdfWhat is ETL? Difference between ETL and ELT?.pdf
What is ETL? Difference between ETL and ELT?.pdf
SaikatBasu37
 
CS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docxCS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docx
nidarizvitit
 
Dr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug - Expert In Artificial IntelligenceDr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug
 
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm     mmmmmfftro.pptxlecture_13 tree in mmmmmmmm     mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
sarajafffri058
 
AI ------------------------------ W1L2.pptx
AI ------------------------------ W1L2.pptxAI ------------------------------ W1L2.pptx
AI ------------------------------ W1L2.pptx
AyeshaJalil6
 
real illuminati Uganda agent 0782561496/0756664682
real illuminati Uganda agent 0782561496/0756664682real illuminati Uganda agent 0782561496/0756664682
real illuminati Uganda agent 0782561496/0756664682
way to join real illuminati Agent In Kampala Call/WhatsApp+256782561496/0756664682
 
Feature Engineering for Electronic Health Record Systems
Feature Engineering for Electronic Health Record SystemsFeature Engineering for Electronic Health Record Systems
Feature Engineering for Electronic Health Record Systems
Process mining Evangelist
 
Time series for yotube_1_data anlysis.pdf
Time series for yotube_1_data anlysis.pdfTime series for yotube_1_data anlysis.pdf
Time series for yotube_1_data anlysis.pdf
asmaamahmoudsaeed
 
Oral Malodor.pptx jsjshdhushehsidjjeiejdhfj
Oral Malodor.pptx jsjshdhushehsidjjeiejdhfjOral Malodor.pptx jsjshdhushehsidjjeiejdhfj
Oral Malodor.pptx jsjshdhushehsidjjeiejdhfj
maitripatel5301
 
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
Taqyea
 
Lesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdfLesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdf
hemelali11
 
CERTIFIED BUSINESS ANALYSIS PROFESSIONAL™
CERTIFIED BUSINESS ANALYSIS PROFESSIONAL™CERTIFIED BUSINESS ANALYSIS PROFESSIONAL™
CERTIFIED BUSINESS ANALYSIS PROFESSIONAL™
muhammed84essa
 
Fundamentals of Data Analysis, its types, tools, algorithms
Fundamentals of Data Analysis, its types, tools, algorithmsFundamentals of Data Analysis, its types, tools, algorithms
Fundamentals of Data Analysis, its types, tools, algorithms
priyaiyerkbcsc
 
RAG Chatbot using AWS Bedrock and Streamlit Framework
RAG Chatbot using AWS Bedrock and Streamlit FrameworkRAG Chatbot using AWS Bedrock and Streamlit Framework
RAG Chatbot using AWS Bedrock and Streamlit Framework
apanneer
 
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdfTOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
NhiV747372
 
Mining a Global Trade Process with Data Science - Microsoft
Mining a Global Trade Process with Data Science - MicrosoftMining a Global Trade Process with Data Science - Microsoft
Mining a Global Trade Process with Data Science - Microsoft
Process mining Evangelist
 
50_questions_full.pptxdddddddddddddddddd
50_questions_full.pptxdddddddddddddddddd50_questions_full.pptxdddddddddddddddddd
50_questions_full.pptxdddddddddddddddddd
emir73065
 
Introduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdfIntroduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdf
AbdurahmanAbd
 
Lagos School of Programming Final Project Updated.pdf
Lagos School of Programming Final Project Updated.pdfLagos School of Programming Final Project Updated.pdf
Lagos School of Programming Final Project Updated.pdf
benuju2016
 
indonesia-gen-z-report-2024 Gen Z (born between 1997 and 2012) is currently t...
indonesia-gen-z-report-2024 Gen Z (born between 1997 and 2012) is currently t...indonesia-gen-z-report-2024 Gen Z (born between 1997 and 2012) is currently t...
indonesia-gen-z-report-2024 Gen Z (born between 1997 and 2012) is currently t...
disnakertransjabarda
 
What is ETL? Difference between ETL and ELT?.pdf
What is ETL? Difference between ETL and ELT?.pdfWhat is ETL? Difference between ETL and ELT?.pdf
What is ETL? Difference between ETL and ELT?.pdf
SaikatBasu37
 
CS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docxCS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docx
nidarizvitit
 
Dr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug - Expert In Artificial IntelligenceDr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug
 
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm     mmmmmfftro.pptxlecture_13 tree in mmmmmmmm     mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
sarajafffri058
 
AI ------------------------------ W1L2.pptx
AI ------------------------------ W1L2.pptxAI ------------------------------ W1L2.pptx
AI ------------------------------ W1L2.pptx
AyeshaJalil6
 
Feature Engineering for Electronic Health Record Systems
Feature Engineering for Electronic Health Record SystemsFeature Engineering for Electronic Health Record Systems
Feature Engineering for Electronic Health Record Systems
Process mining Evangelist
 
Time series for yotube_1_data anlysis.pdf
Time series for yotube_1_data anlysis.pdfTime series for yotube_1_data anlysis.pdf
Time series for yotube_1_data anlysis.pdf
asmaamahmoudsaeed
 
Oral Malodor.pptx jsjshdhushehsidjjeiejdhfj
Oral Malodor.pptx jsjshdhushehsidjjeiejdhfjOral Malodor.pptx jsjshdhushehsidjjeiejdhfj
Oral Malodor.pptx jsjshdhushehsidjjeiejdhfj
maitripatel5301
 
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
Taqyea
 
Lesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdfLesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdf
hemelali11
 
CERTIFIED BUSINESS ANALYSIS PROFESSIONAL™
CERTIFIED BUSINESS ANALYSIS PROFESSIONAL™CERTIFIED BUSINESS ANALYSIS PROFESSIONAL™
CERTIFIED BUSINESS ANALYSIS PROFESSIONAL™
muhammed84essa
 

Binary Tree Traversal

  • 1. Name: Panchal Dhrumil Indravadan Subject: Data Structure Branch: Computer Engineering (B.E.) Semester: Third Sem Year: 2018-19
  • 3.  Binary Tree Traversal  Preorder  Inorder  Postorder  Example
  • 4.  The most common operations performed on tree structure is that of traversal. This is a procedure by which each node in the tree is processed exactly once in a systematic manner.  There are three ways of traversing a binary tree.  1. Preorder Traversal  2. Inorder Traversal  3. Postorder Traversal
  • 5.  Preorder traversal : A B C D E F G  Inorder traversal : C B A E F D G  Postorder traversal : C B F E G D A  Converse Preorder traversal : A D G E F B C  Converse Inorder traversal : G D F E A B C  Converse Postorder traversal : G F E D C B A A B C D E F G
  • 6.  Preorder traversal of a binary tree is defined as follow  Process the root node  Traverse the left subtree in preorder  Traverse the right subtree in preorder  If particular subtree is empty (i.e., node has no left or right descendant) the traversal is performed by doing nothing, In other words, a null subtree is considered to be fully traversed when it is encountered.  The preorder traversal of a tree is given by  A B C D E F G
  • 7.  The Inorder traversal of a binary tree is given by following steps, Traverse the left subtree in Inorder Process the root node Traverse the right subtree in Inorder • The Inorder traversal of a tree is given by • C B A E F D G
  • 8.  The postorder traversal is given by Traverse the left subtree in postorder Traverse the right subtree in postorder Process the root node  The Postorder traversal of a tree is given by  C B F E G D A
  • 9.  If we interchange left and right words in the preceding definitions, we obtain three new traversal orders which are called Converse Preorder (A D G E F B C) Converse Inorder (G D F E A B C) Converse Postorder (G F E D C B A)
  • 10.  Given a binary tree whose root node address is given by pointer variable root and whose node structure is same as described below. This procedure traverses the tree in preorder, in a recursive manner. ROOT LPTR RPTR
  • 11.  void preorder (root)  {  if (root==NULL)  return;  printf (“ %dn ”, root->info);  preorder ( root-> left);  preorder ( root-> right);  }
  • 12.  Given a binary tree whose root node address is given by pointer variable “root” and whose node structure is same as described below. This procedure traverses the tree in inorder, in a recursive manner. LPTR ROOT RPTR
  • 13.  void inorder (root->left)  {  if (root==NULL)  return;  inorder ( root);  printf (“ %dn ”, root->info);  inorder ( root-> right);  }
  • 14.  Given a binary tree whose root node address is given by pointer variable “root” and whose node structure is same as described below. This procedure traverses the tree in postorder, in a recursive manner. LPTR RPTR ROOT
  • 15.  void postorder (root->left)  {  if (root==NULL)  return;  postorder (root-> right);  postorder (root);  printf (“ %dn ”, root->info);  }
  • 16.  Inorder: 2 1 4 5 3  Preorder: 1 2 3 4 5  Post order: 2 5 4 3 1 1 2 3 4 5
  • 17.  Inspiration from Prof. Keyur Suthar and Prof. Rashmin Prajapati  Notes of DS  Textbook of DS  Image from Google images  Some my own knowledge
  翻译: