Download presentation
Presentation is loading. Please wait.
1
7.1 Trees
2
Each element of a tree is called a vertex and noted with a V.
Root Level 0 Level 1 children Level 2 children (also called leaves) Each element of a tree is called a vertex and noted with a V. V0 is the root of the tree. The root of a tree does not have a parent. We write (T, V0 )to denote a rooted tree T with a root of V0 . V0 V1 V3 V2 V5 V6 V7 V8 V9 V4
3
There are no one node cycles in a tree. There is only one root
There are no one node cycles in a tree. There is only one root. The root has an in degree of zero. All other verticies have an in degree of 1. The root is at level zero and is the parent of V1, V2, V3. The children or offspring of the root are at level 1. They are V1, V2, V3. V1, V2, V3 are siblings V4 is a child or offspring of V1. V1 is the parent of V4. V4 has no siblings The children or offspring of V1, V2, V3 are at level 2. V4, V5, V6 , V7, V8 and V9 are all at level 2.
4
The height is the maximum of all levels of its verticies
The height is the maximum of all levels of its verticies. The height of our example is 2. The verticies of the tree that have no offspring are called leaves. The leaves of our example are V4, V5, V6 , V7, V8 and V9
5
Sub trees The following are sub trees of our example.
Each of the leaves is a subtree. V4 V5 V6 V7 V8 V9 V1 V2 V3 V4 V6 V5 V9 V8 V7
6
Trees are: irreflexive, no (a,a),(b,b)…no one node cycles asymmetric aRb bRa not transitive: if you have (a,b) and (b,c) you will not have (a,c) A tree is called an n-tree if every vertex has at most n offspring. If all vertices of T, other than the leaves have exactly n offspring, then the tree is considered to be a complete n-tree.
7
A complete 2-tree is called a complete binary tree.
A 2 tree is called a binary tree. Each vertex has either none, one or two children. A complete 2-tree is called a complete binary tree. a b c d e f g a b c d e f g i h
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.