SlideShare une entreprise Scribd logo
1  sur  69
Binary Trees
Parts of a binary tree ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Picture of a binary tree a b c d e g h i l f j k
Size and depth ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],a b c d e f g h i j k l
Balance ,[object Object],[object Object],a b c d e f g h i j A balanced binary tree a b c d e f g h i j An unbalanced binary tree
Binary search in an array ,[object Object],2 3 5 7 11 13 17 0  1  2  3  4  5  6 Searching for 5: (0+6)/2 = 3 hi = 2; (0 + 2)/2 = 1 lo = 2; (2+2)/2=2 7 3 13 2 5 11 17 Using a binary search tree
Tree traversals ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Preorder traversal ,[object Object],[object Object],[object Object]
Inorder traversal ,[object Object],[object Object],[object Object]
Postorder traversal ,[object Object],[object Object],[object Object]
Tree traversals using “flags” ,[object Object],[object Object],preorder inorder postorder A B C D E F G A B C D E F G A B C D E F G A B D E C F G D B E A F C G D E B F G C A
Copying a binary tree ,[object Object],[object Object],[object Object]
Other traversals ,[object Object],[object Object],[object Object],[object Object],[object Object]
Tree searches ,[object Object],[object Object],L M N O P G Q H J I K F E D B C A Goal nodes
Depth-first searching ,[object Object],[object Object],[object Object],[object Object],L M N O P G Q H J I K F E D B C A
How to do depth-first searching ,[object Object],[object Object],[object Object],[object Object],[object Object]
Depth-First Search A B C D E F G A  B D E C F G Stack: Current:
Depth-First Search A B C D E F G Undiscovered Marked Finished Active B newly discovered Stack: (A, C); (A, B) Current:
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active A already marked Visited B Stack: (B, E); (B, D); (B, A) (A, C); (A, B)
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active A already marked Visited B A Stack: (B, E); (B, D); (B, A) (A, C); (A, B)
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active D newly discovered A Stack: (B, E); (B, D); (B, A) (A, C); (A, B)
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Visited D A   B Stack: (B, E); (B, D); (B, A) (A, C); (A, B) (B, D) Marked B
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Finished D A   B Stack: (B, E); (B, D); (B, A) (A, C); (A, B)
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active E newly discovered Stack: (B, E); (B, D); (B, A) (A, C); (A, B) A  B D Backtrack B
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Visited E Stack: (B, E); (B, D); (B, A) (A, C); (A, B) A  B D (B, E)
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Finished E Stack: (B, E); (B, D); (B, A) (A, C); (A, B) A  B D
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (B, E); (B, D); (B, A) (A, C); (A, B) A  B D E
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (A, C); (A, B) A  B D E Backtrack B
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (A, C); (A, B) A  B D E Backtrack A Finished B C newly discovered
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (C, G); (C, F); (C, A) A  B D E Visited C (A, C); (A, B)
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (C, G); (C, F); (C, A) Marked C (A, C); (A, B) F newly discovered A  B D E C
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (C, G); (C, F); (C, A) (A, C); (A, B) Visited F A  B D E C (F, C)
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (C, G); (C, F); (C, A) (A, C); (A, B) Finished F A  B D E C
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (C, G); (C, F); (C, A) (A, C); (A, B) Backtrack C G newly discovered A  B D E C F
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (C, G); (C, F); (C, A) (A, C); (A, B) Marked C Visited G A  B D E C F (G, C)
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (C, G); (C, F); (C, A) (A, C); (A, B) Backtrack C Finished G A  B D E C F G
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: (A, C); (A, B) Finished C A  B D E C F G Backtrack A
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active Stack: A  B D E C F G Finished A
Depth-First Search A B C D E F G Current: Undiscovered Marked Finished Active A  B D E C F G
Breadth-first searching ,[object Object],[object Object],[object Object],[object Object],L M N O P G Q H J I K F E D B C A
How to do breadth-first searching ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Breadth-First Search A B C D E F G A  B  C  D  E  F  G Queue: Current:
Breadth-First Search A B C D E F G Queue: Current: A
Breadth-First Search A B C D E F G Queue: Current: A A
Breadth-First Search A B C D E F G Queue: Current: A A
Breadth-First Search A B C D E F G Queue: Current: B A A
Breadth-First Search A B C D E F G Queue: Current: C B A A
Breadth-First Search A B C D E F G Queue: Current: B A C B
Breadth-First Search A B C D E F G Queue: Current: B C A  B
Breadth-First Search A B C D E F G Queue: Current: D C B A  B
Breadth-First Search A B C D E F G Queue: Current: E D C B A  B
Breadth-First Search A B C D E F G Queue: Current: C E D C A  B
Breadth-First Search A B C D E F G Queue: Current: C A  B  C E D
Breadth-First Search A B C D E F G Queue: Current: C A  B  C F E D
Breadth-First Search A B C D E F G Queue: Current: C A  B  C G F E D
Breadth-First Search A B C D E F G Queue: Current: D A  B  C G F E D
Breadth-First Search A  B  C  D A B C D E F G Queue: Current: D G F E
Breadth-First Search A B C D E F G A  B  C  D Queue: Current: E G F E
Breadth-First Search A B C D E F G Queue: Current: F G A  B  C  D  E  F
Breadth-First Search A B C D E F G Queue: Current: G G A  B  C  D  E  F
Breadth-First Search A B C D E F G Queue: Current: G A  B  C  D  E  F  G
Breadth-First Search A B C D E F G A  B  C  D  E  F  G
Depth- vs. breadth-first searching ,[object Object],[object Object],[object Object],[object Object],[object Object]
findMin/ findMax ,[object Object],[object Object],[object Object],[object Object]
insert ,[object Object],[object Object],[object Object],[object Object]
delete ,[object Object],[object Object]
Delete cont… ,[object Object],[object Object],[object Object],[object Object],[object Object]
Delete cont… ,[object Object],[object Object],[object Object],[object Object],[object Object]
Thank you for listening!

Contenu connexe

Tendances

Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
ghhgj jhgh
 

Tendances (20)

Binary Tree in Data Structure
Binary Tree in Data StructureBinary Tree in Data Structure
Binary Tree in Data Structure
 
Red black tree
Red black treeRed black tree
Red black tree
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Trees
TreesTrees
Trees
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Linked lists
Linked listsLinked lists
Linked lists
 
Linked List
Linked ListLinked List
Linked List
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 
Binary tree and operations
Binary tree and operations Binary tree and operations
Binary tree and operations
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operations
 
Binary trees1
Binary trees1Binary trees1
Binary trees1
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Red black tree
Red black treeRed black tree
Red black tree
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 

Similaire à (Binary tree)

Data structures algoritghm for binary tree method.ppt
Data structures algoritghm for binary tree method.pptData structures algoritghm for binary tree method.ppt
Data structures algoritghm for binary tree method.ppt
Johny139575
 
09 binary-trees
09 binary-trees09 binary-trees
09 binary-trees
Tech_MX
 

Similaire à (Binary tree) (20)

Bfs & dfs application
Bfs & dfs applicationBfs & dfs application
Bfs & dfs application
 
Breadth First Search (BFS)
Breadth First Search (BFS)Breadth First Search (BFS)
Breadth First Search (BFS)
 
Binary trees
Binary treesBinary trees
Binary trees
 
Uniformed tree searching
Uniformed tree searching Uniformed tree searching
Uniformed tree searching
 
Data structures algoritghm for binary tree method.ppt
Data structures algoritghm for binary tree method.pptData structures algoritghm for binary tree method.ppt
Data structures algoritghm for binary tree method.ppt
 
ISA23 .pptx
ISA23 .pptxISA23 .pptx
ISA23 .pptx
 
Lec216
Lec216Lec216
Lec216
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
bfs[1].pptx
bfs[1].pptxbfs[1].pptx
bfs[1].pptx
 
Lec21
Lec21Lec21
Lec21
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
bca data structure
bca data structurebca data structure
bca data structure
 
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
 
Unit 4.2(graphs)
Unit 4.2(graphs)Unit 4.2(graphs)
Unit 4.2(graphs)
 
09 binary-trees
09 binary-trees09 binary-trees
09 binary-trees
 
ai (1) (1).pptx
ai (1) (1).pptxai (1) (1).pptx
ai (1) (1).pptx
 
Presentasi Eclat
Presentasi EclatPresentasi Eclat
Presentasi Eclat
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Topic18BinaryTrees.pptx
Topic18BinaryTrees.pptxTopic18BinaryTrees.pptx
Topic18BinaryTrees.pptx
 
DS MCQS.pptx
DS MCQS.pptxDS MCQS.pptx
DS MCQS.pptx
 

Plus de almario1988 (20)

Module 1.4 internal analysis
Module 1.4    internal analysisModule 1.4    internal analysis
Module 1.4 internal analysis
 
Module 1.2 basics of technopreneurship
Module 1.2 basics of technopreneurshipModule 1.2 basics of technopreneurship
Module 1.2 basics of technopreneurship
 
Module 1.2 basics of technopreneurship
Module 1.2 basics of technopreneurshipModule 1.2 basics of technopreneurship
Module 1.2 basics of technopreneurship
 
Ppt lesson 17
Ppt lesson 17Ppt lesson 17
Ppt lesson 17
 
Intro ch 09_b
Intro ch 09_bIntro ch 09_b
Intro ch 09_b
 
Intro ch 08_b
Intro ch 08_bIntro ch 08_b
Intro ch 08_b
 
Intro ch 04_b
Intro ch 04_bIntro ch 04_b
Intro ch 04_b
 
Chap01mc
Chap01mcChap01mc
Chap01mc
 
Power point2007 chapter_3
Power point2007 chapter_3Power point2007 chapter_3
Power point2007 chapter_3
 
Intro ch 04_b
Intro ch 04_bIntro ch 04_b
Intro ch 04_b
 
Power point2007 chapter_3
Power point2007 chapter_3Power point2007 chapter_3
Power point2007 chapter_3
 
Power point2007 chapter_2
Power point2007 chapter_2Power point2007 chapter_2
Power point2007 chapter_2
 
Power point2007 chapter_1
Power point2007 chapter_1Power point2007 chapter_1
Power point2007 chapter_1
 
Ppt lesson 05
Ppt lesson 05Ppt lesson 05
Ppt lesson 05
 
Intro ch 04_a
Intro ch 04_aIntro ch 04_a
Intro ch 04_a
 
Ecom
EcomEcom
Ecom
 
Intro ch 05_a
Intro ch 05_aIntro ch 05_a
Intro ch 05_a
 
Intro ch 10_a
Intro ch 10_aIntro ch 10_a
Intro ch 10_a
 
Intro ch 02_b
Intro ch 02_bIntro ch 02_b
Intro ch 02_b
 
Ethics for IT Professionals and IT Users
Ethics for IT Professionals and IT UsersEthics for IT Professionals and IT Users
Ethics for IT Professionals and IT Users
 

Dernier

Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 

Dernier (20)

Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 

(Binary tree)