View by Category

Loading...

PPT – Trees PowerPoint presentation | free to view

The Adobe Flash plugin is needed to view this content

About This Presentation

Write a Comment

User Comments (0)

Transcript and Presenter's Notes

Trees

- Terminology and Characterizations
- Spanning Trees
- Minimal Spanning Trees
- Binary Trees
- Tree Traversals
- Decision Trees
- Isomorphisms of Trees

Introduction

- Family trees use vertices to represent the

members of a family and edges to represent

parent-child relationships

Introduction

- A computer file system

Introduction

- A file system in Visual Studio .NET

Introduction

- A tree T is a simple graph satisfying If v and w

are vertices in T, there is a unique simple path

from v to w. - A rooted tree is a tree in which a particular

vertex is designated the root.

Introduction

- Which of the graphs are trees?

Terminology of Trees

- Let v0 be root, suppose that x, y and z are

vertices and that (v0, v1, ..., vn) is a simple

path. - vn-1 is the parent of vn.
- v0, v1, ..., vn-1 are ancestors of vn.
- vn is a child of vn-1.
- If x is an ancestor of y, y is descendant of x.
- If x and y are children of z, x and y are

siblings - If x has no children, x is terminal vertex (or

leaf) - If x is not terminal vertex, x is an internal

vertex.

Terminology of Trees

Properties of Trees

- Let T be a graph with n vertices. The following

are equivalent. - T is a tree.
- T is connected and acyclic.
- T is connected and has n-1 edges.
- T is acyclic and has n-1 edges.
- Prove if (d) then (a)

Binary Tree

- In a binary tree, an internal vertex has two

children, left child and right child. - The tree rooted at the left child of a vertex is

called the left subtree of this vertex.

Binary Tree

- A full binary tree is a binary tree in which each

vertex has either two children or no children. - If T is a full binary tree with i internal

vertices, then T has i1 terminal vertices and

2i1 total vertices. - If a binary tree of height h has t terminal

vertices, then lg t ? h

Huffman Coding

- When us bit strings to encode the letters of the

English alphabet. - We use 5 bits to represent each of 26 letters
- The total number of bits used to encode data is

five times the number of characters in the text. - Saving memory space, transmittal time.
- Is there a coding scheme to encode text with

fewer bits? - Huffman coding. (a graduate term paper by Huffman

at MIT) - The scheme assumes that we already know how many

times each letter occurs in the text!

Huffman Coding

- procedure Huffman (C symbols ai with frequencies

wi) - F forest of n rooted trees, each

consisting of - the single vertex ai and assigned

weight wi - while F is not a tree
- begin
- Replace the rooted trees T and T of

least weights - from F with w(T) w(T) with a tree

having a new - root that has T s its left subtree

and T as its right - subtree. Lable the new edge to T

with 0 and the - new edge to T with 1.
- Assign w(T) w(T) as the weight of

the new tree - end
- end Huffman

Huffman Coding

- Use Huffman coding to encode the following

symbols with frequencies listed A 0.08, B0.10,

C0.12, D0.15, E0.20, F0.35

Huffman Coding

- Use Huffman coding to encode these symbols with

given frequencies a 0.20, b 0.10, c 0.15, d

0.25, e 0.30. What is the average number of bits

required to encode a character?

Binary Search Trees

- A binary search tree is a binary tree in which
- each child of a vertex is designated as a right

or left child, with each vertex labeled with a

key - the key at a vertex is larger than the keys of

all vertices in its left subtree and smaller than

the keys of all vertices in its right subtree.

Binary Search Trees

- To build a binary search tree
- Create a root node, and assign the first item in

the list as the key of the root node - To add a new item, repeatedly compare the new

item with the keys of vertices already in the

tree - if the item is less than the key of the vertex,

move to the left - if the item is greater than the key of the

vertex, move to the right - If the item is less than the respective vertex

and this vertex has no left child, add a new

vertex with this item as a new left child. - If the item is greater than the respective vertex

and this vertex has no right child, add a new

vertex with this item as a new right child. - Repeat steps 2-4 add another items in the list to

the tree.

Binary Search Trees

- To build a binary search tree for words

mathematics, physics, gegraphy, zoology,

meteorology, geology, psychology, and chemistry

procedure make_bin_search_tree(w, n) let T

be the tree with one vertex, root store w1

in root for i 2 to n do begin

v root search true while

search do begin s

word in v if wi lt s then

if v has no left child then add a left

child l to v store wi in l

search false else v left child of

v else if v has

no right child then add a right child r to v

store wi in r search

false else v right child of

v end end end

make_bin_search_tree

Binary Search Trees

- To build a binary search tree for words
- Old Programmers Never Die They Just Lose Their

Memories

Decision Trees

- A decision tree is a rooted tree in which each

internal vertex corresponds to a decision, with a

subtree at these vertices for each possible

outcome of the decision.

Decision Trees

- To sort three numbers, a1, a2, and a3.

Tree Traversal

- Ordered rooted trees are used to store

information, such as arithmetic expressions

involving numbers, variables, and operations. - To traverse a tree, we use a labeling scheme

called universal address system of the ordered

rooted tree. - Label the root with the integer 0. Then label its

k children from left to right with 1, 2, 3, ...,

k. - For each vertex v at level n with label A, label

its children from left to right with A.1, A.2,

..., A.m.

Tree Traversal

Preorder Tree Traversal

- procedure preorder(PT)
- if PT is empty then
- return
- process PT
- preorder( the left subtree of PT )
- preorder( the right subtree of PT )
- end preorder

Preorder Tree Traversal

- In which order does a preorder traversal visit

the vertices in the ordered rooted tree T shown?

Inorder Tree Traversal

- procedure inorder(PT)
- if PT is empty then
- return
- inorder( the left subtree of PT )
- process PT
- inorder( the right subtree of PT )
- end inorder

Inorder Tree Traversal

- In which order does an inorder traversal visit

the vertices in the ordered rooted tree T shown?

Infix Form of an Expression

- Using inorder traversal, we get

Operands A, B, C, D, E Operators , -, , /

Arithmetic Expressions

- The expression ((xy)?2)((x-4)/3) may be

represented as a rooted binary tree.

Arithmetic Expressions

- What is the inorder traversal of the binary tree?
- infix form
- What is the preorder traversal?
- prefix form

Spanning Trees

- Consider the road system in Minnesota. The

highway department needs to plow the fewest roads

in winter, so that, there are always cleared

roads connecting any two towns. - But, how?
- To find a connected subgraph with the minimum

number of edges containing all vertices

Spanning Trees

Spanning Trees

- A spanning tree of G is a subgraph of G that is a

tree containing every vertex of G. - Example IP multicasting
- A computer sends a single copy of data over the

network. For data to reach receiving computers as

quickly as possible, there should be no loops.

Depth-First Search

- procedure dfs(V, E)
- w v1 V v1 E ??
- while V ? V do
- while there is edge (w, vk) with vk ? V
- add (w, vk) to E
- add vk to V
- w vk
- w parent of w in T //backtracking
- end dfs

Depth-First Search

- Choose a vertex as a root.
- Successively add vertices and edges, where each

new edge is incident with the last vertex in the

path and the new vertex is not in the path yet. - If the path goes through all vertices of the

graph, we have the spanning tree. - Otherwise, move back to the next to last vertex

in the path, and form a new path starting at this

vertex through vertices that were not visited yet.

Depth-First Search

- Find the spanning tree rooted at f

Breath-First Search

- Choose a root vertex
- Add all edges incident to this vertex.
- Order all newly added vertices
- For each new vertex, add each edge incident to

this vertex as long as it does not form a cycle - Repeat steps 3 and 4

Breath-First Search

- procedure bfs(V, E)
- S (v1), V v1, E ??
- while true do
- for each x?? S, in order, do
- if (x, y) is an edge not forming

a cycle then - add edge (x, y) to E
- add y to V
- if no edges were added then
- return(T)
- S children of S
- end bfs

Breath-First Search

- Find the spanning tree rooted at e

Minimum spanning Trees

- A minimum spanning tree of G is a spanning tree

of G with minimum weight. - Example a company plans to build a communication

network connecting its five computer enters. Any

pair of these centers can be linked with a leased

telephone line. Which links should be made to

ensure that there is a path between any two

computer centers so that the total cost of the

network is minimized?

Minimum spanning Trees

- The Prims Algorithm builds a tree by iteratively

adding edges until a minimal spanning tree is

obtained. At each iteration, it adds a

minimum-weight edge that does not complete a

cycle to the current tree. - Prims Algorithm is a greedy algorithm.

Minimum spanning Trees

- procedure prim(w, n, s)
- for i 1 to n do
- v(i) 0 v(s) 1 E ??
- for i 1 to n-1 do
- min ?
- for j 1 to n do
- if v(j) 1 then
- for k1 to n do
- if v(k) 0

and w(j, k) lt min then - add_vertex k
- e

(j, k) min w(j, k) - v( add_vertex ) 1
- E E ? e
- end prim

Prims Algorithm

Prims Algorithm

- Use Prims algorithm to find a minimum spanning

tree

Isomorphic Trees

- Let T1 and T2 be rooted trees with roots r1 and

r2. T1 and T2 are isomorphic if there is a

one-to-one, onto function f from the vertex set

of T1 to the vertex set of T2 satisfying - Vertices vi and vj are adjacent in T1 if and only

if the vertices f(vi) and f(vj) are adjacent in

T2. - f(r1) r2.

Nonisomorphisms Trees

- Three nonisomorphic trees with five vertices.

- Four nonisomorphic trees with four vertices.

Isomorphic Binary Trees

- Let T1 and T2 be binary trees with roots r1 and

r2. The T1 and T2 are isomorphic if there is a

non-to-one, onto function f satisfying - T1 and T2 are isomorphic tree.
- v is a left child of w in T1 iff f(v) is the left

child of f(w) in T2. - v is a right child of w in T1 iff f(v) is the

right child of f(w) in T2.

Isomorphic Binary Trees

- Five nonisomorphic binary trees with three

vertices

v1

Isomorphic Binary Trees

- procedure bin_tree_isom (r1, r2)
- if r1 null and r2 null then
- return (true)
- if r1 null or r2 null then
- return (false)
- lc_r1 left child of r1
- lc_r2 left child of r2
- rc_r1 right child of r1
- rc_r2 right child of r2
- return ( bin_tree_isom(lc_r1, lc_r2)
- and bin_tree_isom(rc_r1,

lc_r2) ) - end bin_tree_isom

About PowerShow.com

PowerShow.com is a leading presentation/slideshow sharing website. Whether your application is business, how-to, education, medicine, school, church, sales, marketing, online training or just for fun, PowerShow.com is a great resource. And, best of all, most of its cool features are free and easy to use.

You can use PowerShow.com to find and download example online PowerPoint ppt presentations on just about any topic you can imagine so you can learn how to improve your own slides and presentations for free. Or use it to find and download high-quality how-to PowerPoint ppt presentations with illustrated or animated slides that will teach you how to do something new, also for free. Or use it to upload your own PowerPoint slides so you can share them with your teachers, class, students, bosses, employees, customers, potential investors or the world. Or use it to create really cool photo slideshows - with 2D and 3D transitions, animation, and your choice of music - that you can share with your Facebook friends or Google+ circles. That's all free as well!

For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!

You can use PowerShow.com to find and download example online PowerPoint ppt presentations on just about any topic you can imagine so you can learn how to improve your own slides and presentations for free. Or use it to find and download high-quality how-to PowerPoint ppt presentations with illustrated or animated slides that will teach you how to do something new, also for free. Or use it to upload your own PowerPoint slides so you can share them with your teachers, class, students, bosses, employees, customers, potential investors or the world. Or use it to create really cool photo slideshows - with 2D and 3D transitions, animation, and your choice of music - that you can share with your Facebook friends or Google+ circles. That's all free as well!

For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!

presentations for free. Or use it to find and download high-quality how-to PowerPoint ppt presentations with illustrated or animated slides that will teach you how to do something new, also for free. Or use it to upload your own PowerPoint slides so you can share them with your teachers, class, students, bosses, employees, customers, potential investors or the world. Or use it to create really cool photo slideshows - with 2D and 3D transitions, animation, and your choice of music - that you can share with your Facebook friends or Google+ circles. That's all free as well!

For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!

For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!

Recommended

«

/ »

Page of

«

/ »

Promoted Presentations

Related Presentations

Page of

Page of

CrystalGraphics Sales Tel: (800) 394-0700 x 1 or Send an email

Home About Us Terms and Conditions Privacy Policy Contact Us Send Us Feedback

Copyright 2014 CrystalGraphics, Inc. — All rights Reserved. PowerShow.com is a trademark of CrystalGraphics, Inc.

Copyright 2014 CrystalGraphics, Inc. — All rights Reserved. PowerShow.com is a trademark of CrystalGraphics, Inc.

The PowerPoint PPT presentation: "Trees" is the property of its rightful owner.

Do you have PowerPoint slides to share? If so, share your PPT presentation slides online with PowerShow.com. It's FREE!

Committed to assisting Winona University and other schools with their online training by sharing educational presentations for free