SlideShare a Scribd company logo
Tree Traversals (In-order, Pre-order and Post-order)
How to Find PRI-ORDER, IN-ORDER, POST-ORDER
Traversal in TREE.
• As we all know there are certain rules (or manner) that we have to follow for Traversal
in tree.
• Pri-Order :- Root, Left, Right.
• In-Order :-Left, Root, Right.
• Post-Order :-Left, Right, Root .
• Sometimes it’s confusing that what manner we have to follow for PRI-Oder, IN-Order,
POSTER-Order Traversal.
• So now we see how to do In-order, Pri-order and Post-order traversal in different
manner.
Tree Traversals (In-order, Pre-order and Post-order)
Left, Right, Bottom side of NODE.
50Left-hand side of Node Right-hand side of Node
Bottom side of Node
Tree Traversals (In-order, Pre-order and Post-order)
For PRI-ORDER TRAVERSAL.
IF YOU ARE IN LEFT-HAND SIDE OF NODE THEN YOU
HAVE TO WRITE THAT VALUE IN OUTPUT.
50
Pri-Order:-
50
• IF YOU ARE IN BOTTOM OF THE NODE THEN YOU DON’T
HAVE TO WRITE ANYTHING IN OUTPUT.
50
Pri-Order:- NULL
PRI-ORDER TRAVERSAL
• IF YOU ARE IN RIGHT-HAND SIDE OF THE NODE THEN
ALSO YOU DON’T HAVE TO WRITE ANTHING IN OUTPUT.
50
Pri-Order:- NULL
PRI-ORDER TRAVERSAL
Now see how to follow this steps in TREE Traversal.
50
35
20 45 7060
80
Example.
Draw one imaginary path around given TREE
Step 1:
35
20 45 9060
80
5050
PRI-ORDER:- .
20
35
45
80
60 90
IF YOU ARE IN LEFT HAND
SIDE OF NODE THEN YOU
HAVE TO WRITE THAT VALUE
IN OUTPUT
Tree Traversals (In-order, Pre-order and Post-order)
For IN-ORDER TRAVERSAL.
IF YOU ARE IN LEFT-HAND SIDE OF NODE THEN YOU
DON’T HAVE TO WRITE ANYTHING IN OUTPUT.
50
IN-Order:-NULL
50
• IF YOU ARE IN BOTTOM OF THE NODE THEN YOU HAVE
TO WRITE THAT VALUE IN OUTPUT.
50
IN-Order:-
50
IN-ORDER TRAVERSAL
• IF YOU ARE IN RIGHT-HAND SIDE OF THE NODE THEN
YOU DON’T HAVE TO WRITE ANYTHING IN OUTPUT.
50
IN-Order:- NULL
IN-ORDER TRAVERSAL
50
35
20 45 7060
80
Example.
Draw one imaginary path around given TREE
Step 1:
50
35
20 45 9060
80
Let’s see one example.
IF YOU ARE IN BOTTOM
SIDE OF NODE THEN YOU
HAVE TO WRITE THAT
VALUE IN OUTPUT
20
IN-ORDER:- .
35
45
50
60
80
90
Tree Traversals (In-order, Pre-order and Post-order)
For POST-ORDER TRAVERSAL.
IF YOU ARE IN LEFT-HAND SIDE OF NODE THEN YOU
DON’T HAVE TO WRITE THAT VALUE IN OUTPUT.
50
POST-Order:-NULL
50
• IF YOU ARE IN BOTTOM OF THE NODE THEN YOU DON’T
HAVE TO WRITE ANYTING IN OUTPUT.
50
POST-Order:-NULL
POST-ORDER TRAVERSAL
• IF YOU ARE IN RIGHT-HAND SIDE OF THE NODE THEN
YOU HAVE TO WRITE THAT VALUE IN OUTPUT.
50
POST-Order:-
50
POST-ORDER TRAVERSAL
50
35
20 45 7060
80
Example.
Draw one imaginary path around given TREE
Step 1:
50
35
20 45 9060
80
Let’s see one example.
Post-Order:- .
20
IF YOU ARE IN RIGHT-
HAND SIDE OF NODE
THEN YOU HAVE TO
WRITE THAT VALUE
IN OUTPUT
45
35
60 90
80
50
Conclusion
• PRI-ORDER :- Consider the value If you are in LEFT-HAND SIDE
of the NODE.
• IN-ORDER :- Consider the value if you are in BOTTOM SIDE
of the NODE
• POST-ORDER:- Consider the value If you are in RIGHT-HAND SIDE
of the NODE.
50
50
50
• Still if you have any queries then ask them on.
Email:-Upadhyayraj007@gmail.com
Ad

More Related Content

What's hot (20)

Exploring Fractions Grade 3-4
Exploring Fractions Grade 3-4Exploring Fractions Grade 3-4
Exploring Fractions Grade 3-4
susan70
 
Matrix Operations
Matrix OperationsMatrix Operations
Matrix Operations
Ron Eick
 
Taylor and maclaurian series
Taylor and maclaurian seriesTaylor and maclaurian series
Taylor and maclaurian series
Darshan Aswani
 
Frequency Distributions
Frequency DistributionsFrequency Distributions
Frequency Distributions
jasondroesch
 
Matrix Algebra seminar ppt
Matrix Algebra seminar pptMatrix Algebra seminar ppt
Matrix Algebra seminar ppt
Swetalina Pradhan
 
Functions in mathematics
Functions in mathematicsFunctions in mathematics
Functions in mathematics
Burhanuddin Shabbir
 
Boxplot
BoxplotBoxplot
Boxplot
Kelly Jans
 
Matrix and its operations
Matrix and its operationsMatrix and its operations
Matrix and its operations
Pankaj Das
 
Understanding fractions
Understanding fractionsUnderstanding fractions
Understanding fractions
BillyCharlie
 
Set Theory Presentation
Set Theory PresentationSet Theory Presentation
Set Theory Presentation
Mohammad Saffat-E-Nayeem
 
Squaring of numbers
Squaring of numbersSquaring of numbers
Squaring of numbers
Krishna Kumawat
 
Quartile
QuartileQuartile
Quartile
Kemberly Lee
 
Percentiles and Deciles
Percentiles and DecilesPercentiles and Deciles
Percentiles and Deciles
Mary Espinar
 
Matrices and Determinants
Matrices and DeterminantsMatrices and Determinants
Matrices and Determinants
SOMASUNDARAM T
 
Non –verbal reasoning
Non –verbal reasoningNon –verbal reasoning
Non –verbal reasoning
Veeraragavan Subramaniam
 
Introduction of matrices
Introduction of matricesIntroduction of matrices
Introduction of matrices
Shakehand with Life
 
7.5 Matrices and Matrix Operations
7.5 Matrices and Matrix Operations7.5 Matrices and Matrix Operations
7.5 Matrices and Matrix Operations
smiller5
 
Matrix algebra
Matrix algebraMatrix algebra
Matrix algebra
Farzad Javidanrad
 
Fractions decimals-and-percents
Fractions decimals-and-percentsFractions decimals-and-percents
Fractions decimals-and-percents
tvierra
 
Mathematical operations
Mathematical operationsMathematical operations
Mathematical operations
Arjuna Senanayake
 
Exploring Fractions Grade 3-4
Exploring Fractions Grade 3-4Exploring Fractions Grade 3-4
Exploring Fractions Grade 3-4
susan70
 
Matrix Operations
Matrix OperationsMatrix Operations
Matrix Operations
Ron Eick
 
Taylor and maclaurian series
Taylor and maclaurian seriesTaylor and maclaurian series
Taylor and maclaurian series
Darshan Aswani
 
Frequency Distributions
Frequency DistributionsFrequency Distributions
Frequency Distributions
jasondroesch
 
Matrix and its operations
Matrix and its operationsMatrix and its operations
Matrix and its operations
Pankaj Das
 
Understanding fractions
Understanding fractionsUnderstanding fractions
Understanding fractions
BillyCharlie
 
Percentiles and Deciles
Percentiles and DecilesPercentiles and Deciles
Percentiles and Deciles
Mary Espinar
 
Matrices and Determinants
Matrices and DeterminantsMatrices and Determinants
Matrices and Determinants
SOMASUNDARAM T
 
7.5 Matrices and Matrix Operations
7.5 Matrices and Matrix Operations7.5 Matrices and Matrix Operations
7.5 Matrices and Matrix Operations
smiller5
 
Fractions decimals-and-percents
Fractions decimals-and-percentsFractions decimals-and-percents
Fractions decimals-and-percents
tvierra
 

More from raj upadhyay (12)

JavaScript Regular Expression Match
JavaScript Regular Expression MatchJavaScript Regular Expression Match
JavaScript Regular Expression Match
raj upadhyay
 
Basics of java (1)
Basics of java (1)Basics of java (1)
Basics of java (1)
raj upadhyay
 
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
raj upadhyay
 
Folder Can't Delete How to Remove FILES That Won't Delete?
 Folder Can't Delete How to Remove FILES That Won't Delete? Folder Can't Delete How to Remove FILES That Won't Delete?
Folder Can't Delete How to Remove FILES That Won't Delete?
raj upadhyay
 
Recovering unallocated space of a usb flash drive
Recovering unallocated space of a usb flash driveRecovering unallocated space of a usb flash drive
Recovering unallocated space of a usb flash drive
raj upadhyay
 
Terminal commands ubuntu 2
Terminal commands ubuntu 2Terminal commands ubuntu 2
Terminal commands ubuntu 2
raj upadhyay
 
Terminal Commands (Linux - ubuntu) (part-1)
Terminal Commands  (Linux - ubuntu) (part-1)Terminal Commands  (Linux - ubuntu) (part-1)
Terminal Commands (Linux - ubuntu) (part-1)
raj upadhyay
 
Find out Which Versions of the .NET Framework are Installed on a PC.
Find out Which Versions of the .NET Framework are Installed on a PC.Find out Which Versions of the .NET Framework are Installed on a PC.
Find out Which Versions of the .NET Framework are Installed on a PC.
raj upadhyay
 
Relational Algebra,Types of join
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of join
raj upadhyay
 
PL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMSPL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMS
raj upadhyay
 
How to get notification from google group
How to get notification from google groupHow to get notification from google group
How to get notification from google group
raj upadhyay
 
Disadvantages of file management system (file processing systems)
Disadvantages of file management system(file processing systems)Disadvantages of file management system(file processing systems)
Disadvantages of file management system (file processing systems)
raj upadhyay
 
JavaScript Regular Expression Match
JavaScript Regular Expression MatchJavaScript Regular Expression Match
JavaScript Regular Expression Match
raj upadhyay
 
Basics of java (1)
Basics of java (1)Basics of java (1)
Basics of java (1)
raj upadhyay
 
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
raj upadhyay
 
Folder Can't Delete How to Remove FILES That Won't Delete?
 Folder Can't Delete How to Remove FILES That Won't Delete? Folder Can't Delete How to Remove FILES That Won't Delete?
Folder Can't Delete How to Remove FILES That Won't Delete?
raj upadhyay
 
Recovering unallocated space of a usb flash drive
Recovering unallocated space of a usb flash driveRecovering unallocated space of a usb flash drive
Recovering unallocated space of a usb flash drive
raj upadhyay
 
Terminal commands ubuntu 2
Terminal commands ubuntu 2Terminal commands ubuntu 2
Terminal commands ubuntu 2
raj upadhyay
 
Terminal Commands (Linux - ubuntu) (part-1)
Terminal Commands  (Linux - ubuntu) (part-1)Terminal Commands  (Linux - ubuntu) (part-1)
Terminal Commands (Linux - ubuntu) (part-1)
raj upadhyay
 
Find out Which Versions of the .NET Framework are Installed on a PC.
Find out Which Versions of the .NET Framework are Installed on a PC.Find out Which Versions of the .NET Framework are Installed on a PC.
Find out Which Versions of the .NET Framework are Installed on a PC.
raj upadhyay
 
Relational Algebra,Types of join
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of join
raj upadhyay
 
PL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMSPL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMS
raj upadhyay
 
How to get notification from google group
How to get notification from google groupHow to get notification from google group
How to get notification from google group
raj upadhyay
 
Disadvantages of file management system (file processing systems)
Disadvantages of file management system(file processing systems)Disadvantages of file management system(file processing systems)
Disadvantages of file management system (file processing systems)
raj upadhyay
 
Ad

Recently uploaded (20)

Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
Ad

Tree Traversals (In-order, Pre-order and Post-order)

  • 2. How to Find PRI-ORDER, IN-ORDER, POST-ORDER Traversal in TREE. • As we all know there are certain rules (or manner) that we have to follow for Traversal in tree. • Pri-Order :- Root, Left, Right. • In-Order :-Left, Root, Right. • Post-Order :-Left, Right, Root . • Sometimes it’s confusing that what manner we have to follow for PRI-Oder, IN-Order, POSTER-Order Traversal. • So now we see how to do In-order, Pri-order and Post-order traversal in different manner.
  • 4. Left, Right, Bottom side of NODE. 50Left-hand side of Node Right-hand side of Node Bottom side of Node
  • 6. For PRI-ORDER TRAVERSAL. IF YOU ARE IN LEFT-HAND SIDE OF NODE THEN YOU HAVE TO WRITE THAT VALUE IN OUTPUT. 50 Pri-Order:- 50
  • 7. • IF YOU ARE IN BOTTOM OF THE NODE THEN YOU DON’T HAVE TO WRITE ANYTHING IN OUTPUT. 50 Pri-Order:- NULL PRI-ORDER TRAVERSAL
  • 8. • IF YOU ARE IN RIGHT-HAND SIDE OF THE NODE THEN ALSO YOU DON’T HAVE TO WRITE ANTHING IN OUTPUT. 50 Pri-Order:- NULL PRI-ORDER TRAVERSAL
  • 9. Now see how to follow this steps in TREE Traversal.
  • 11. Draw one imaginary path around given TREE Step 1:
  • 12. 35 20 45 9060 80 5050 PRI-ORDER:- . 20 35 45 80 60 90 IF YOU ARE IN LEFT HAND SIDE OF NODE THEN YOU HAVE TO WRITE THAT VALUE IN OUTPUT
  • 14. For IN-ORDER TRAVERSAL. IF YOU ARE IN LEFT-HAND SIDE OF NODE THEN YOU DON’T HAVE TO WRITE ANYTHING IN OUTPUT. 50 IN-Order:-NULL 50
  • 15. • IF YOU ARE IN BOTTOM OF THE NODE THEN YOU HAVE TO WRITE THAT VALUE IN OUTPUT. 50 IN-Order:- 50 IN-ORDER TRAVERSAL
  • 16. • IF YOU ARE IN RIGHT-HAND SIDE OF THE NODE THEN YOU DON’T HAVE TO WRITE ANYTHING IN OUTPUT. 50 IN-Order:- NULL IN-ORDER TRAVERSAL
  • 18. Draw one imaginary path around given TREE Step 1:
  • 19. 50 35 20 45 9060 80 Let’s see one example. IF YOU ARE IN BOTTOM SIDE OF NODE THEN YOU HAVE TO WRITE THAT VALUE IN OUTPUT 20 IN-ORDER:- . 35 45 50 60 80 90
  • 21. For POST-ORDER TRAVERSAL. IF YOU ARE IN LEFT-HAND SIDE OF NODE THEN YOU DON’T HAVE TO WRITE THAT VALUE IN OUTPUT. 50 POST-Order:-NULL 50
  • 22. • IF YOU ARE IN BOTTOM OF THE NODE THEN YOU DON’T HAVE TO WRITE ANYTING IN OUTPUT. 50 POST-Order:-NULL POST-ORDER TRAVERSAL
  • 23. • IF YOU ARE IN RIGHT-HAND SIDE OF THE NODE THEN YOU HAVE TO WRITE THAT VALUE IN OUTPUT. 50 POST-Order:- 50 POST-ORDER TRAVERSAL
  • 25. Draw one imaginary path around given TREE Step 1:
  • 26. 50 35 20 45 9060 80 Let’s see one example. Post-Order:- . 20 IF YOU ARE IN RIGHT- HAND SIDE OF NODE THEN YOU HAVE TO WRITE THAT VALUE IN OUTPUT 45 35 60 90 80 50
  • 27. Conclusion • PRI-ORDER :- Consider the value If you are in LEFT-HAND SIDE of the NODE. • IN-ORDER :- Consider the value if you are in BOTTOM SIDE of the NODE • POST-ORDER:- Consider the value If you are in RIGHT-HAND SIDE of the NODE. 50 50 50
  • 28. • Still if you have any queries then ask them on. Email:-Upadhyayraj007@gmail.com
  翻译: