Trees and Tree Traversals - PowerPoint PPT Presentation

1 / 46
About This Presentation
Title:

Trees and Tree Traversals

Description:

Title: Trees and Tree Traversals Author: Lee Last modified by: Lee Created Date: 2/20/2004 5:00:12 PM Document presentation format: On-screen Show Other titles – PowerPoint PPT presentation

Number of Views:96
Avg rating:3.0/5.0
Slides: 47
Provided by: Lee144
Category:

less

Transcript and Presenter's Notes

Title: Trees and Tree Traversals


1
Trees and Tree Traversals
CS146 Lecture 7
  • Prof. Sin-Min Lee
  • Department of Computer Science
  • San Jose State University

2
Outline
  • Graph-Tree
  • Basic Definition
  • Rooted Trees
  • Applications of Trees
  • Game Tree

3
(No Transcript)
4
(No Transcript)
5
(No Transcript)
6
(No Transcript)
7
(No Transcript)
8
(No Transcript)
9
Basic Definition
  • Tree
  • a connected graph with no simple circuits
  • No multiple edges or loops
  • Theorems
  • a graph is a tree iff a unique simple path
    between any two of its vertices
  • A tree with n vertices has n 1 edges
  • Forest

10
(No Transcript)
11
(No Transcript)
12
Rooted Tree
  • Is a directed graph T satisfying
  • It is a tree when the directions of the edges are
    ignored.
  • There is a unique vertex r (called the root) such
    that the indegree of r is 0 and the indegree of
    any other vertex is 1.
  • Examples family tree, position tree
  • Terminology parent, child, terminal vertex,
    internal vertex, subtree, ancestor, descendant
  • An m-ary tree, A full m-ary tree, A balanced
    m-ary tree with height h

13
Order Rooted Tree
  • Is a rooted tree where the children of each
    internal vertex are ordered.
  • ordered binary tree two child, left/right

14
(No Transcript)
15
(No Transcript)
16
(No Transcript)
17
Tree Traversal
  • Is a procedure that systematically visits every
    vertex of an ordered rooted tree
  • Three most commonly used algorithms
  • Preorder traversal.
  • Inorder traversal.
  • Postorder traversal.

18
(No Transcript)
19
(No Transcript)
20
Example1
  • List three kinds of traversals.

21
Binary Search Trees
  • Is a binary tree in which each vertex is labeled
    with a key such that
  • No two vertices have the same key
  • If vertex u belongs to the left subtree of vertex
    v, then u ? v
  • If vertex w belongs to the right subtree of
    vertex v, then v ? w
  • construction algorithm

22
(No Transcript)
23
S122223s4262263
2S2222324262263264
26424260 161018
2S-SS264-1
150 years to get this produce
24
  A Pale Blue Planet Mourns the Passing of a
Passionate Scientist
Carl Sagan (1934-1996.12.20)
25
(No Transcript)
26
(No Transcript)
27
(No Transcript)
28
(No Transcript)
29
(No Transcript)
30
(No Transcript)
31
(No Transcript)
32
(No Transcript)
33
(No Transcript)
34
(No Transcript)
35
(No Transcript)
36
(No Transcript)
37
(No Transcript)
38
(No Transcript)
39
(No Transcript)
40
(No Transcript)
41
(No Transcript)
42
(No Transcript)
43
(No Transcript)
44
(No Transcript)
45
(No Transcript)
46
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com