SlideShare a Scribd company logo
1 of 24
Tree
Adam M.B.
TREE
TRAVERSAL

Types of Tree Traversal
• Preorder : Node – Left - Right
• Inorder : Left – Node - Right
• Postorder : Left – Right - Node
Ilustration (1)
H
A
L
K
B
C J
Preorder (NLR) : HA KCB JL
Inorder (LNR) : HA KCB J L
Postorder (LRN) : HA KCB JL
Ilustration (2)
Preorder (NLR) : ABDE C GH
Inorder (LNR) :
Postorder (LRN) :
A
B
H
CD
E F
GI
I F
ABD E CGHI F
ABDE CGHI F
Case
Prefix : / + A- B DH
Infix :
Postfix:
/
+
^
-
A
B
F
*
D
* ^
E = A + BDH – F
G - K
A + B * D^ H- F )( / G( - )E = K
H
-
KG
GK-F
/+A -B D H* ^ G K-F
/+A -BDH *^ GK -F
Subtree Kiri Subtree
Kanan
Root
Make binary tree from this general tree
and do the tree traversal process:
Exercise
A
B
H
C
D E F GI
R
P
Q
TREE TRAVERSAL
INTO BINARY TREE

Example 1
Preorder :
Inorder :
J
B
H
CD
E F
GI
BDEI F GJC H
DIEB F CJH G
Example 2
Inorder :
Postorder :
J
B
H
CD
E F
GI
IEDH F CBG J
DIEB F CJH G
Make binary tree from these result of tree
traversal:
• Inorder : BCDFGKMPSUWY
Preorder : MFDBCKGSPWUY
• Postorder : EGHCIMFBNPJLKDA
Inorder : EBGCHFMIANJPDLK
Exercise
m
TREE TRAVERSAL
USING STACK

Node have 2
Using Preorder
Rules :
• If scanned node has 2 children then
PUSH its right son (RS).
• If scanned node hasn’t child then POP
element of stack.
Node have 2
Using Preorder
Notes :
• Arrow down (↓) means PUSH.
• Arrow up (↑) means POP.
• LS : Left Son
• RS : Right Son
Node have 2
Using Preorder
A
B
H
CD
E F
GI
Preorder (NLR) :
Head B D E I C
F G H A
BDEICFGHA
LS RS LS
RS B RS B
LS RS RS
RS C
RS C
Node have 2
Using Inorder
Rules and Note :
• If scanned node has left child then PUSH
itself (Scanned Node Address).
• If scanned node hasn’t child then POP
element of stack.
• Add = Address.
Node have 2
Using Inorder
A
B
H
CD
E F
GI
Inorder (LNR) :
Head B D E I E
B C F G
DIEBFGHCA
LS RS LS
Add. B Add. E
RS LS
Add. C
Add. BAdd. E
Add. C
RS RS H
RSC A
Node have 2
Using Postorder
Rules :
• If scanned node has 2 children then PUSH
itself (Scanned Node Address) and its right
child.
• If scanned node has only 1 child then PUSH
itself (Scanned Node Address).
• If scanned node hasn’t child then POP element
of stack.
Node have 2
Using Postorder
A
B
H
CD
E F
GI
Postorder (LRN) :
Head B D E I E
D C F G
IEDHGFACB
LS RS LS
RS B
Add. E
LS
RS B
Add. D
G F A C
H
Add B
RS
Add C
Add D Add E
RS C
Add C Add F
RS
Add G Add G
Add F RS C
B
Add B
Traverse this tree using stack (3 ways):
Exercise 1
A
B
H
C
D E
FI
Make binary tree from this statement then
traverse binary tree using stack (3 ways):
Exercise 2
E = A + (B-D)H – F
GK
Make binary in linked list form from these result
of tree traversal and traverse the result using
stack in postorder way:
Preorder : RFCAEDLHPVTZXWY
Inorder : ACDEFHLPRTVWXYZ
Exercise 3
Make binary tree from this general tree and traverse
the result using preorder, inorder, and postorder:
Exercise 4
S
B
L
D
E F J K
MC
G H
I
N P
X
A PY
Contact Person:
Adam Mukharil Bachtiar
Informatics Engineering UNIKOM
Jalan Dipati Ukur Nomor. 112-114 Bandung 40132
Email: adfbipotter@gmail.com
Blog: http://adfbipotter.wordpress.com
Copyright © Adam Mukharil Bachtiar 2012

More Related Content

Viewers also liked

Looking for a radiant skin, look out for radiation
Looking for a radiant skin, look out for radiationLooking for a radiant skin, look out for radiation
Looking for a radiant skin, look out for radiationFrançois Christiaens
 
Installation & configuration of IBM Cloud Orchestrator v2.5
Installation & configuration of IBM Cloud Orchestrator v2.5Installation & configuration of IBM Cloud Orchestrator v2.5
Installation & configuration of IBM Cloud Orchestrator v2.5Paulraj Pappaiah
 
Mutant Testing: um mundo para um X-Testing.
Mutant Testing: um mundo para um X-Testing.Mutant Testing: um mundo para um X-Testing.
Mutant Testing: um mundo para um X-Testing.Robson Agapito Correa
 
Guazzaroni M. Nuove Metodiche Radiologiche nelle Emergenze Stroke. ASMaD 2012
Guazzaroni M. Nuove Metodiche Radiologiche nelle Emergenze Stroke. ASMaD 2012Guazzaroni M. Nuove Metodiche Radiologiche nelle Emergenze Stroke. ASMaD 2012
Guazzaroni M. Nuove Metodiche Radiologiche nelle Emergenze Stroke. ASMaD 2012Gianfranco Tammaro
 
данные и устройства для работы с ними
данные и устройства для работы с нимиданные и устройства для работы с ними
данные и устройства для работы с нимиliza2209
 
графические объекты
графические объектыграфические объекты
графические объектыliza2209
 
компьютерные презентации
компьютерные презентациикомпьютерные презентации
компьютерные презентацииliza2209
 
правила складання ребусів
правила складання ребусівправила складання ребусів
правила складання ребусівliza2209
 
Verizon taking over yahoo
Verizon taking over yahooVerizon taking over yahoo
Verizon taking over yahooAvneet Singh
 
интересные факты о информатике
интересные факты о информатикеинтересные факты о информатике
интересные факты о информатикеliza2209
 
Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Adam Mukharil Bachtiar
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary treeZaid Shabbir
 

Viewers also liked (14)

Looking for a radiant skin, look out for radiation
Looking for a radiant skin, look out for radiationLooking for a radiant skin, look out for radiation
Looking for a radiant skin, look out for radiation
 
Installation & configuration of IBM Cloud Orchestrator v2.5
Installation & configuration of IBM Cloud Orchestrator v2.5Installation & configuration of IBM Cloud Orchestrator v2.5
Installation & configuration of IBM Cloud Orchestrator v2.5
 
Mutant Testing: um mundo para um X-Testing.
Mutant Testing: um mundo para um X-Testing.Mutant Testing: um mundo para um X-Testing.
Mutant Testing: um mundo para um X-Testing.
 
Guazzaroni M. Nuove Metodiche Radiologiche nelle Emergenze Stroke. ASMaD 2012
Guazzaroni M. Nuove Metodiche Radiologiche nelle Emergenze Stroke. ASMaD 2012Guazzaroni M. Nuove Metodiche Radiologiche nelle Emergenze Stroke. ASMaD 2012
Guazzaroni M. Nuove Metodiche Radiologiche nelle Emergenze Stroke. ASMaD 2012
 
данные и устройства для работы с ними
данные и устройства для работы с нимиданные и устройства для работы с ними
данные и устройства для работы с ними
 
графические объекты
графические объектыграфические объекты
графические объекты
 
компьютерные презентации
компьютерные презентациикомпьютерные презентации
компьютерные презентации
 
правила складання ребусів
правила складання ребусівправила складання ребусів
правила складання ребусів
 
Verizon taking over yahoo
Verizon taking over yahooVerizon taking over yahoo
Verizon taking over yahoo
 
интересные факты о информатике
интересные факты о информатикеинтересные факты о информатике
интересные факты о информатике
 
Yahoo analysis-
Yahoo analysis-Yahoo analysis-
Yahoo analysis-
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
 
Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 

More from Adam Mukharil Bachtiar

Materi 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdfMateri 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdfAdam Mukharil Bachtiar
 
Clean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful NamesClean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful NamesAdam Mukharil Bachtiar
 
Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic ProgrammingAnalisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic ProgrammingAdam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and ConquerAnalisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and ConquerAdam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAdam Mukharil Bachtiar
 
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute ForceAnalisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute ForceAdam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAdam Mukharil Bachtiar
 
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi AlgoritmaAnalisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi AlgoritmaAdam Mukharil Bachtiar
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAdam Mukharil Bachtiar
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAdam Mukharil Bachtiar
 

More from Adam Mukharil Bachtiar (20)

Materi 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdfMateri 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdf
 
Clean Code - Formatting Code
Clean Code - Formatting CodeClean Code - Formatting Code
Clean Code - Formatting Code
 
Clean Code - Clean Comments
Clean Code - Clean CommentsClean Code - Clean Comments
Clean Code - Clean Comments
 
Clean Method
Clean MethodClean Method
Clean Method
 
Clean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful NamesClean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful Names
 
Model Driven Software Development
Model Driven Software DevelopmentModel Driven Software Development
Model Driven Software Development
 
Scrum: How to Implement
Scrum: How to ImplementScrum: How to Implement
Scrum: How to Implement
 
Pengujian Perangkat Lunak
Pengujian Perangkat LunakPengujian Perangkat Lunak
Pengujian Perangkat Lunak
 
Data Mining Clustering
Data Mining ClusteringData Mining Clustering
Data Mining Clustering
 
Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)
 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic ProgrammingAnalisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic Programming
 
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and ConquerAnalisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and Conquer
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma Greedy
 
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute ForceAnalisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute Force
 
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi AlgoritmaAnalisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi Asimptotik
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi Asimptotik
 
Activity Diagram
Activity DiagramActivity Diagram
Activity Diagram
 
UML dan Use Case View
UML dan Use Case ViewUML dan Use Case View
UML dan Use Case View
 

Recently uploaded

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 

Recently uploaded (20)

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 

Data Structure (Tree Continued)

  • 3. Types of Tree Traversal • Preorder : Node – Left - Right • Inorder : Left – Node - Right • Postorder : Left – Right - Node
  • 4. Ilustration (1) H A L K B C J Preorder (NLR) : HA KCB JL Inorder (LNR) : HA KCB J L Postorder (LRN) : HA KCB JL
  • 5. Ilustration (2) Preorder (NLR) : ABDE C GH Inorder (LNR) : Postorder (LRN) : A B H CD E F GI I F ABD E CGHI F ABDE CGHI F
  • 6. Case Prefix : / + A- B DH Infix : Postfix: / + ^ - A B F * D * ^ E = A + BDH – F G - K A + B * D^ H- F )( / G( - )E = K H - KG GK-F /+A -B D H* ^ G K-F /+A -BDH *^ GK -F Subtree Kiri Subtree Kanan Root
  • 7. Make binary tree from this general tree and do the tree traversal process: Exercise A B H C D E F GI R P Q
  • 8. TREE TRAVERSAL INTO BINARY TREE 
  • 9. Example 1 Preorder : Inorder : J B H CD E F GI BDEI F GJC H DIEB F CJH G
  • 10. Example 2 Inorder : Postorder : J B H CD E F GI IEDH F CBG J DIEB F CJH G
  • 11. Make binary tree from these result of tree traversal: • Inorder : BCDFGKMPSUWY Preorder : MFDBCKGSPWUY • Postorder : EGHCIMFBNPJLKDA Inorder : EBGCHFMIANJPDLK Exercise
  • 13. Node have 2 Using Preorder Rules : • If scanned node has 2 children then PUSH its right son (RS). • If scanned node hasn’t child then POP element of stack.
  • 14. Node have 2 Using Preorder Notes : • Arrow down (↓) means PUSH. • Arrow up (↑) means POP. • LS : Left Son • RS : Right Son
  • 15. Node have 2 Using Preorder A B H CD E F GI Preorder (NLR) : Head B D E I C F G H A BDEICFGHA LS RS LS RS B RS B LS RS RS RS C RS C
  • 16. Node have 2 Using Inorder Rules and Note : • If scanned node has left child then PUSH itself (Scanned Node Address). • If scanned node hasn’t child then POP element of stack. • Add = Address.
  • 17. Node have 2 Using Inorder A B H CD E F GI Inorder (LNR) : Head B D E I E B C F G DIEBFGHCA LS RS LS Add. B Add. E RS LS Add. C Add. BAdd. E Add. C RS RS H RSC A
  • 18. Node have 2 Using Postorder Rules : • If scanned node has 2 children then PUSH itself (Scanned Node Address) and its right child. • If scanned node has only 1 child then PUSH itself (Scanned Node Address). • If scanned node hasn’t child then POP element of stack.
  • 19. Node have 2 Using Postorder A B H CD E F GI Postorder (LRN) : Head B D E I E D C F G IEDHGFACB LS RS LS RS B Add. E LS RS B Add. D G F A C H Add B RS Add C Add D Add E RS C Add C Add F RS Add G Add G Add F RS C B Add B
  • 20. Traverse this tree using stack (3 ways): Exercise 1 A B H C D E FI
  • 21. Make binary tree from this statement then traverse binary tree using stack (3 ways): Exercise 2 E = A + (B-D)H – F GK
  • 22. Make binary in linked list form from these result of tree traversal and traverse the result using stack in postorder way: Preorder : RFCAEDLHPVTZXWY Inorder : ACDEFHLPRTVWXYZ Exercise 3
  • 23. Make binary tree from this general tree and traverse the result using preorder, inorder, and postorder: Exercise 4 S B L D E F J K MC G H I N P X A PY
  • 24. Contact Person: Adam Mukharil Bachtiar Informatics Engineering UNIKOM Jalan Dipati Ukur Nomor. 112-114 Bandung 40132 Email: adfbipotter@gmail.com Blog: http://adfbipotter.wordpress.com Copyright © Adam Mukharil Bachtiar 2012