Your SlideShare is downloading.
×

×
# Saving this for later?

### Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

#### Text the download link to your phone

Standard text messaging rates apply

Like this presentation? Why not share!

- Software Testing by Softwarecentral 514 views
- Seminar kiem chungphanmem@nn-tu by Jenny Nguyen 210 views
- (Graham Brown mobileYouth) 50 Youth... by Graham Brown 1163 views
- Software testing training in ahmeda... by neil modi 480 views
- (Graham Brown mobileYouth) Youth M... by Graham Brown 957 views
- Social media by daysi 4355 views
- Jeep Cherokee Vs. Honda Pilot Vehic... by Fullerton Chrysle... 117 views
- Guidline testprocess by Jenny Nguyen 155 views
- (Graham Brown mobileYouth) 50 Youth... by Graham Brown 6207 views
- D3_Guiavarch by ICLEI_ITC 471 views
- Buick dealership serving Shoemakers... by kutztownauto 16 views
- mobileYouth trends download: Droide... by Graham Brown 1419 views

Like this? Share it with your network
Share

404

views

views

Published on

Discrete Structure.

Discrete Structure.

No Downloads

Total Views

404

On Slideshare

0

From Embeds

0

Number of Embeds

0

Shares

0

Downloads

18

Comments

0

Likes

2

No embeds

No notes for slide

- 1. A tree is a finite set of one or more nodes such that:There is a specially designated node called the root.The remaining nodes are partitioned into n>=0 disjoint sets T1, ..., Tn, where each of these sets is a tree.We call T1, ..., Tn the subtrees of the root.
- 2. CrownChurch of England Cabinet House of Commons House of Lords Supreme Court Ministers County Council Metropolitan police Rural District Council County Borough Council
- 3. Levelnode (13)degree of a node A 1leaf (terminal) 3 1Non terminalparent B C D2 2 2 2 1 2 3childrensibling E F G H I J 2 30 30 31 3 0 30 3 3degree of a tree (3)ancestor K L M 4 0 40 4 0 4level of a nodeheight of a tree (4)
- 4. ♣ The degree of a node is the number of subtrees of the node ◙ The degree of A is 3; the degree of C is 1.♣ The node with degree 0 is a leaf or terminal node.♣ A node that has subtrees is the parent of the roots of the subtrees.♣ The roots of these subtrees are the children of the node.♣ Children of the same parent are siblings.♣ The ancestors of a node are all the nodes along the path from the root to the node.
- 5. Property Value A Number of nodes 9 Height 5 B C Root Node A Leaves C,D,F,H,ID E F Interior nodes A,B,E,G Number of levels 5 Ancestors of H G,E,B,A G Descendants of B E,G,H,I Siblings of E GH I
- 6. ◛Every tree node: object – useful information children – pointers to its children nodes OO O O O
- 7. Two main methods: ► Preorder ► Postorder Recursive definition▓ PREorder: ► visit the root ► traverse in preorder the children (subtrees)▓ POSTorder ► traverse in postorder the children (subtrees) ► visit the root
- 8. Algorithm preorder(v) “visit” node v for each child w of v do recursively perform preorder(w)In simple language first Root node is traversed then Left child then Right child is traversed. Root Node 1 Left Child 2 3 Right Child 4 5 6 7 8 9 10 11 12 13 14 15
- 9. Algorithm postorder(v) for each child w of v do recursively perform postorder(w) “visit” node vIn simple language first Left child is traversed then Right child then Root node is traversed. Root Node 1 Left Child 2 3 Right Child 4 5 6 7 8 9 10 11 12 13 14 15
- 10. ◘ A special class of trees: max degree for each node is 2◘ Recursive definition: A binary tree is a finite set of nodes that is either empty or consists of a root and two disjoint binary trees called the left subtree and the right subtree.◘ Any tree can be transformed into binary tree. ◚ By left child-right sibling representation
- 11. A B E C G DK F H L M I J
- 12. The maximum number of nodes on level i of a binary tree is 2i- 1, i>=1.The maximum number of nodes in a binary tree of depth k is 2k- 1, k>=1. Prove by induction k 2 i 1 2 k 1 i 1
- 13. If a complete binary tree with n nodes (depth = log n + 1) isrepresented sequentially, then for any node with index i,1<=i<=n, we have: parent(i) is at i/2 if i!=1. If i=1, i is at the root and has no parent. leftChild(i) is at 2i if 2i<=n. If 2i>n, then i has no left child. rightChild(i) is at 2i+1 if 2i +1 <=n. If 2i +1 >n, then i has no right child.

Be the first to comment