joseph lindo trees sir joseph lindo university of the cordilleras
TRANSCRIPT
![Page 1: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/1.jpg)
Joseph Lindo
Trees
Sir Joseph LindoUniversity of the Cordilleras
![Page 2: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/2.jpg)
Joseph Lindo
BST
Cases
Traversals
Binary Tree
Trees
Course TitleTree
In computer science, a tree is an abstract model of a hierarchical structure
Trees
![Page 3: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/3.jpg)
Joseph Lindo
BST
Cases
Traversals
Binary Tree
Trees
Course TitleBinary Tree
A binary tree is a finite set of elements that is either empty or is partitioned into three disjoint subsets.
The other two subsets are themselves binary trees called the left and right subtrees.
Binary Trees
![Page 4: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/4.jpg)
Joseph Lindo
BST
Cases
Traversals
Binary Tree
Trees
Course TitleBinary Tree
The other two subsets are themselves binary trees called the left and right subtrees.
• Ordered Tree• Full binary tree• Skewed binary tree
Binary Trees
![Page 5: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/5.jpg)
Joseph Lindo
BST
Cases
Traversals
Binary Tree
Trees
Course TitleBinary SearchTree• All identifiers in the left
subtree are less than the identifier in the root node
• All identifiers in the right subtree are greater than the identifier in the root node
BST
![Page 6: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/6.jpg)
Joseph Lindo
BST
Cases
Traversals
Binary Tree
Trees
Course TitleTraversing• It is the process of visiting
each node in a tree exactly one.
Common traversals:Traversals
![Page 7: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/7.jpg)
Joseph Lindo
BST
Cases
Traversals
Binary Tree
Trees
Course TitleTraversals• Preorder
Node - Left - Right • InorderLeft - Node -Right
• PostorderLeft - Right - Node• Level - order
Traversals
Want an easy way to do INORDER
Traversal?
SQUISHING
![Page 8: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/8.jpg)
Joseph Lindo
Trees
-- end --Sir Joseph Lindo
University of the Cordilleras
![Page 9: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/9.jpg)
Joseph Lindo
Trees
-- end na --Sir Joseph Lindo
University of the Cordilleras
![Page 10: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/10.jpg)
Joseph Lindo
Applications
Tree
Organization charts
File systems Programming
environments
![Page 11: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/11.jpg)
Joseph Lindo
Terminologies
Tree
Node Root Node Parent Node Siblings Internal Node External
Node/Leaf/ Terminal
![Page 12: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/12.jpg)
Joseph Lindo
Terminologies
Tree
Ancestors Descendants Subtree Level Depth Height Degree Weigth
![Page 13: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/13.jpg)
Joseph Lindo
Properties
Binary Tree
• 2i-1: maximum number of nodes on level I of a binary tree
• 2k-1: maximum number of nodes in a binary tree of height k
![Page 14: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/14.jpg)
Joseph Lindo
Examples
Traversals
![Page 15: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/15.jpg)
Joseph Lindo
Squishing
INORDER Traversal
![Page 16: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/16.jpg)
Joseph Lindo
Level - Order
Traversal
![Page 17: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/17.jpg)
Joseph Lindo
Trees
-- end --Sir Joseph Lindo
University of the Cordilleras
![Page 18: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/18.jpg)
Joseph Lindo
Trees
-- end na --Sir Joseph Lindo
University of the Cordilleras
![Page 19: Joseph Lindo Trees Sir Joseph Lindo University of the Cordilleras](https://reader037.vdocuments.mx/reader037/viewer/2022103123/56649db95503460f94aa9140/html5/thumbnails/19.jpg)
Joseph Lindo
Examples