SlideShare une entreprise Scribd logo
1  sur  86
Trees and Graphs Trees, Binary Search Trees, Balanced Trees, Graphs ,[object Object],[object Object],[object Object]
Table of Contents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tree-like Data Structures Trees, Balanced Trees, Graphs, Networks
Tree-like Data Structures ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tree-like Data Structures Tree Graph 2 3 6 1 4 5 5   (20) 5   (10) 15   (15) 15   (30) 5   (5) 20(20) 10   (40) Network Project Manager Team Leader De-signer QA Team Leader Developer  1 Developer 2 Tester 1 Developer 3 Tester 2 7 19 21 14 1 12 31 4 11
Trees and Related Terminology Node, Edge, Root, Children, Parent, Leaf , Binary Search Tree, Balanced Tree
Trees ,[object Object],[object Object],Height = 2 Depth 0 Depth 1 Depth 2 17 15 14 9 6 5 8
Binary Trees ,[object Object],[object Object],10 17 15 9 6 5 8 Root node Left subtree Right child Right child Left child
Binary Search Trees ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Binary Search Trees (2) ,[object Object],[object Object],17 19 9 6 12 25
Implementing Trees Recursive Tree Data Structure
Recursive Tree Definition ,[object Object],[object Object],[object Object],[object Object],public class TreeNode<T> { private T value; private List<TreeNode<T>> children; … } The value contained in the node List of child nodes, which are of the same type
TreeNode<int>  Structure TreeNode<int> int value List<TreeNode<int>> children 7 children 19 children 21 children 14 children 1 children 12 children 31 children 23 children 6 children
Implementing  TreeNode <T> public TreeNode(T value) { this.value = value; this.children = new List<TreeNode<T>>(); } public T Value { get { return this.value; } set { this.value = value; } } public void AddChild(TreeNode<T> child) { child.hasParent = true; this.children.Add(child); } public TreeNode<T> GetChild(int index) { return this.children[index]; }
[object Object],Implementing  Tree<T> public class Tree<T> { private TreeNode<T> root; public Tree(T value, params Tree<T>[] children): this(value) { foreach (Tree<T> child in children) { this.root.AddChild(child.root); } } public TreeNode<T> Root { get {  return this.root; } } } Flexible constructor for building trees
Building a Tree ,[object Object],Tree<int> tree = new Tree<int>(7, new Tree<int>(19, new Tree<int>(1), new Tree<int>(12), new Tree<int>(31)), new Tree<int>(21), new Tree<int>(14, new Tree<int>(23), new Tree<int>(6)) ); 7 14 19 23 6 21 31 1 12
Tree Traversals DFS and BFS Traversals
Tree Traversal Algorithms ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],Depth-First  Search (DFS) DFS(node) { for each child  c  of node DFS( c ); print the current node; } 1 2 3 4 5 8 6 7 9 7 14 19 23 6 21 31 1 12
DFS in Action (Step  1 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  2 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  3 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  4 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  5 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  6 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  7 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  8 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  9 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  10 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  11 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  12 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  13 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  14 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  15 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  16 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  17 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
DFS in Action (Step  18 ) ,[object Object],[object Object],Traversal finished 7 14 19 23 6 21 31 1 12
[object Object],[object Object],Breadth-First  Search (BFS) BFS(node) { queue    node while queue not empty v     queue print v for each child  c  of  v queue     c } 5 6 7 2 3 4 8 9 1 7 14 19 23 6 21 31 1 12
BFS in Action (Step  1 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  2 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  3 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  4 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  5 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  6 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  7 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  8 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  9 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  10 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  11 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  12 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  13 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  14 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  15 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  16 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  16 ) ,[object Object],[object Object],7 14 19 23 6 21 31 1 12
BFS in Action (Step  17 ) ,[object Object],[object Object],The queue is empty    stop 7 14 19 23 6 21 31 1 12
Binary Trees   DFS Traversals ,[object Object],[object Object],[object Object],[object Object],17 19 9 6 12 25
Iterative DFS and BFS ,[object Object],[object Object],BFS(node) { queue    node while queue not empty v     queue print v for each child  c  of  v queue     c } DFS(node) { stack    node while stack not empty v     stack print v for each child  c  of  v stack     c }
Trees and Traversals Live Demo
Balanced Search Trees AVL Trees, B-Trees, Red-Black Trees, AA-Trees
Balanced Binary Search Trees ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Balanced Binary Search Tree – Example 33 18 15 24 3 17 20 29 54 42 60 37 43 59 85
Balanced Binary Search Trees ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
B-Trees ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],B-Tree – Example 17 21 7 11 18 20 26 31 2 4 5 6 8 9 12 16 22 23 25 27 29 30 32 35
Balanced Trees in .NET ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Graphs Definitions, Representation, Traversal Algorithms
Graph Data Structure ,[object Object],[object Object],[object Object],Node with multiple predecessors Node with multiple successors 7 19 21 14 1 12 31 4 11
Graph Definitions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],A Node A Edge B
Graph Definitions (2) ,[object Object],[object Object],[object Object],[object Object],7 19 21 1 12 4 3 22 2 3 G J F D A E C H
Graph Definitions (3) ,[object Object],[object Object],3 G J F D A E C H Q K N 10 4 14 6 16 9 8 7 5 22
Graph Definitions (4) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],G C B A H N K
Graph Definitions (5) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],G C B A H N K
Graph Definitions (6) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],G C B A H N K
Graph Definitions (8) ,[object Object],[object Object],[object Object],[object Object],Unconnected graph with two connected components G J F D A Connected graph G J F D A E C H
Graphs and Their Applications ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Representing Graphs ,[object Object],[object Object],[object Object],[object Object],[object Object],1 2 3 4 1 2 3 4 {1,2} {1,4} {2,3} {3,1} {4,2} 1    {2, 4} 2    {3} 3    {1} 4    {2} 0 1 0 1 0 0 1 0 1 0 0 0 0 1 0 0 2 4 1 3
Representing Graphs in C# public class Graph { int[][] childNodes; public Graph(int[][] nodes) { this.childNodes = nodes; } } Graph g = new Graph(new int[][] { new int[] {3, 6}, // successors of vertice 0 new int[] {2, 3, 4, 5, 6}, // successors of vertice 1 new int[] {1, 4, 5}, // successors of vertice 2 new int[] {0, 1, 5}, // successors of vertice 3 new int[] {1, 2, 6}, // successors of vertice 4 new int[] {1, 2, 3}, // successors of vertice 5 new int[] {0, 1, 4}  // successors of vertice 6 }); 0 6 4 1 5 2 3
Graph Traversal Algorithms ,[object Object],[object Object],BFS( node ) { queue     node visited[ node ] = true while queue not empty v     queue print  v for each child  c  of  v if not visited[ c ] queue     c visited[ c ] = true } DFS( node ) { stack     node visited[ node ] = true while stack not empty v     stack print  v for each child  c  of  v if not visited[ c ] stack     c visited[ c ] = true }
Recursive DFS Graph Traversal void TraverseDFSRecursive(node) { if (not visited[node]) { visited[node] = true print node foreach child node  c  of node { TraverseDFSRecursive( c ); } } } vois Main() { TraverseDFS(firstNode); }
Graphs and Traversals Live Demo
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Trees and Graphs ,[object Object],http://academy.telerik.com
Exercises ,[object Object],[object Object]
Exercises (2) ,[object Object],[object Object],[object Object],[object Object]
Exercises (3) ,[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Tendances (20)

Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structure
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Trees and graphs
Trees and graphsTrees and graphs
Trees and graphs
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Binary Tree in Data Structure
Binary Tree in Data StructureBinary Tree in Data Structure
Binary Tree in Data Structure
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 
Tree Traversal
Tree TraversalTree Traversal
Tree Traversal
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Disjoint sets
Disjoint setsDisjoint sets
Disjoint sets
 
Slide 6 er strong & weak entity
Slide 6 er  strong & weak entitySlide 6 er  strong & weak entity
Slide 6 er strong & weak entity
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Graph Basic In Data structure
Graph Basic In Data structureGraph Basic In Data structure
Graph Basic In Data structure
 
Trees
TreesTrees
Trees
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Binary tree
Binary tree Binary tree
Binary tree
 

En vedette

Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
chandsek666
 
Heuristic Search
Heuristic SearchHeuristic Search
Heuristic Search
butest
 
Alphorm.com Support de la Formation PHP MySQL
Alphorm.com Support de la Formation PHP MySQLAlphorm.com Support de la Formation PHP MySQL
Alphorm.com Support de la Formation PHP MySQL
Alphorm
 

En vedette (19)

14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
 
08. Numeral Systems
08. Numeral Systems08. Numeral Systems
08. Numeral Systems
 
0. Course Introduction
0. Course Introduction0. Course Introduction
0. Course Introduction
 
20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles
 
Algorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class NotesAlgorithm Analysis and Design Class Notes
Algorithm Analysis and Design Class Notes
 
ADA complete notes
ADA complete notesADA complete notes
ADA complete notes
 
Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure
 
Search algorithms master
Search algorithms masterSearch algorithms master
Search algorithms master
 
130210107039 2130702
130210107039 2130702130210107039 2130702
130210107039 2130702
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first search
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
 
Heuristic Search
Heuristic SearchHeuristic Search
Heuristic Search
 
Linear and Binary Search Algorithms.(Discrete Mathematics)
Linear and Binary Search Algorithms.(Discrete Mathematics)Linear and Binary Search Algorithms.(Discrete Mathematics)
Linear and Binary Search Algorithms.(Discrete Mathematics)
 
Application of dfs
Application of dfsApplication of dfs
Application of dfs
 
Hillclimbing search algorthim #introduction
Hillclimbing search algorthim #introductionHillclimbing search algorthim #introduction
Hillclimbing search algorthim #introduction
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Alphorm.com Support de la Formation PHP MySQL
Alphorm.com Support de la Formation PHP MySQLAlphorm.com Support de la Formation PHP MySQL
Alphorm.com Support de la Formation PHP MySQL
 

Similaire à 17. Trees and Graphs

4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
venkatapranaykumarGa
 
lecture 17
lecture 17lecture 17
lecture 17
sajinsc
 

Similaire à 17. Trees and Graphs (18)

17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
 
17 Trees and graphs
17 Trees and graphs17 Trees and graphs
17 Trees and graphs
 
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptxData Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
 
Traversals | Data Structures
Traversals | Data StructuresTraversals | Data Structures
Traversals | Data Structures
 
Data Structures and Agorithm: DS 18 Heap.pptx
Data Structures and Agorithm: DS 18 Heap.pptxData Structures and Agorithm: DS 18 Heap.pptx
Data Structures and Agorithm: DS 18 Heap.pptx
 
Lecture_10 - Revised.pptx
Lecture_10 - Revised.pptxLecture_10 - Revised.pptx
Lecture_10 - Revised.pptx
 
Using Topological Data Analysis on your BigData
Using Topological Data Analysis on your BigDataUsing Topological Data Analysis on your BigData
Using Topological Data Analysis on your BigData
 
RSX™ Best Practices
RSX™ Best PracticesRSX™ Best Practices
RSX™ Best Practices
 
Visualization of Supervised Learning with {arules} + {arulesViz}
Visualization of Supervised Learning with {arules} + {arulesViz}Visualization of Supervised Learning with {arules} + {arulesViz}
Visualization of Supervised Learning with {arules} + {arulesViz}
 
17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like Structures
 
B tree by-jash acharya
B tree by-jash acharyaB tree by-jash acharya
B tree by-jash acharya
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
bca data structure
bca data structurebca data structure
bca data structure
 
Binary Trees
Binary TreesBinary Trees
Binary Trees
 
8. Recursion.pptx
8. Recursion.pptx8. Recursion.pptx
8. Recursion.pptx
 
All I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School AlgebraAll I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School Algebra
 
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
 
lecture 17
lecture 17lecture 17
lecture 17
 

Plus de Intro C# Book

Plus de Intro C# Book (20)

Java Problem solving
Java Problem solving Java Problem solving
Java Problem solving
 
21. Java High Quality Programming Code
21. Java High Quality Programming Code21. Java High Quality Programming Code
21. Java High Quality Programming Code
 
20.5 Java polymorphism
20.5 Java polymorphism 20.5 Java polymorphism
20.5 Java polymorphism
 
20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulation
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritance
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity
 
18. Java associative arrays
18. Java associative arrays18. Java associative arrays
18. Java associative arrays
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queues
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classes
 
13. Java text processing
13.  Java text processing13.  Java text processing
13. Java text processing
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 
11. Java Objects and classes
11. Java  Objects and classes11. Java  Objects and classes
11. Java Objects and classes
 
09. Java Methods
09. Java Methods09. Java Methods
09. Java Methods
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and Classes
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...
 
02. Data Types and variables
02. Data Types and variables02. Data Types and variables
02. Data Types and variables
 
01. Introduction to programming with java
01. Introduction to programming with java01. Introduction to programming with java
01. Introduction to programming with java
 

Dernier

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Dernier (20)

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...
 
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
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreel
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 

17. Trees and Graphs

  • 1.
  • 2.
  • 3. Tree-like Data Structures Trees, Balanced Trees, Graphs, Networks
  • 4.
  • 5. Tree-like Data Structures Tree Graph 2 3 6 1 4 5 5 (20) 5 (10) 15 (15) 15 (30) 5 (5) 20(20) 10 (40) Network Project Manager Team Leader De-signer QA Team Leader Developer 1 Developer 2 Tester 1 Developer 3 Tester 2 7 19 21 14 1 12 31 4 11
  • 6. Trees and Related Terminology Node, Edge, Root, Children, Parent, Leaf , Binary Search Tree, Balanced Tree
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Implementing Trees Recursive Tree Data Structure
  • 12.
  • 13. TreeNode<int> Structure TreeNode<int> int value List<TreeNode<int>> children 7 children 19 children 21 children 14 children 1 children 12 children 31 children 23 children 6 children
  • 14. Implementing TreeNode <T> public TreeNode(T value) { this.value = value; this.children = new List<TreeNode<T>>(); } public T Value { get { return this.value; } set { this.value = value; } } public void AddChild(TreeNode<T> child) { child.hasParent = true; this.children.Add(child); } public TreeNode<T> GetChild(int index) { return this.children[index]; }
  • 15.
  • 16.
  • 17. Tree Traversals DFS and BFS Traversals
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59. Trees and Traversals Live Demo
  • 60. Balanced Search Trees AVL Trees, B-Trees, Red-Black Trees, AA-Trees
  • 61.
  • 62. Balanced Binary Search Tree – Example 33 18 15 24 3 17 20 29 54 42 60 37 43 59 85
  • 63.
  • 64.
  • 65.
  • 66.
  • 67. Graphs Definitions, Representation, Traversal Algorithms
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78. Representing Graphs in C# public class Graph { int[][] childNodes; public Graph(int[][] nodes) { this.childNodes = nodes; } } Graph g = new Graph(new int[][] { new int[] {3, 6}, // successors of vertice 0 new int[] {2, 3, 4, 5, 6}, // successors of vertice 1 new int[] {1, 4, 5}, // successors of vertice 2 new int[] {0, 1, 5}, // successors of vertice 3 new int[] {1, 2, 6}, // successors of vertice 4 new int[] {1, 2, 3}, // successors of vertice 5 new int[] {0, 1, 4} // successors of vertice 6 }); 0 6 4 1 5 2 3
  • 79.
  • 80. Recursive DFS Graph Traversal void TraverseDFSRecursive(node) { if (not visited[node]) { visited[node] = true print node foreach child node c of node { TraverseDFSRecursive( c ); } } } vois Main() { TraverseDFS(firstNode); }
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.

Notes de l'éditeur

  1. * (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  2. * (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  3. * (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  4. * (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  5. * (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  6. * (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  7. * (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  8. * (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  9. * (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  10. * (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  11. * (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  12. * (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  13. * (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##