2 views

Uploaded by Sheraz Ali

discrete structure tree slides

- twenty question , john T .pdf
- Dror Bar-Natan and Zsuzsanna Dancso- Homomorphic Expansions for Knotted Trivalent Graphs- Fixing an Anomoly
- Binary Tree
- [Universitext] Peter Morris (Auth.) - Introduction to Game Theory (1994, Springer-Verlag New York)
- AVL trees
- Traversal
- daslides-c
- Greedy
- Binary Search Tree
- Graph Theory
- Grade 11 Exam Review
- Saharon Shelah and Joel Spencer- Can You Feel the Double Jump
- 1989-40
- Binomial Theorem.pdf
- Combinatorial Geometry with Applications to Field Theory, Second Edition, graduate textbook in mathematics, by Linfan Mao
- Tutorial 5 Sol
- b11084-3
- Frontiers of Computational Journalism - Columbia Journalism School Fall 2012 - Week 9: Social Network Analysis
- 460-HeapDeap
- Counting

You are on page 1of 37

Trees

Definition: Let be a set, and let be a relation on .

We say that is a tree if there is a vertex 0 in with

the property that

1) there exists a unique path in from 0 to every

other vertex in ,

2) no path from 0 to 0 .

referred to as a rooted tree denoted by , 0 .

Trees

Theorem: Let , 0 be a rooted tree. Then

has in-degree one, and 0 has in-degree zero.

Levels, Parent-Offspring, Siblings

Level 1 vertices: the vertices of

the edges beginning at 0 (level 0)

1

Level vertices: the vertices of the

edges beginning at those level 1

vertices

2 3 4

Height of a tree: the largest level number

of a tree

5

is called the parent of and is called

the offspring of

parent

Leaves: the vertices that have no

offspring

S. Turaev, CSC 1700 Discrete Mathematics 4

Levels, Parent-Offspring, Siblings

Root 1 Level 0

Parent

2 3 4 Level 1

Leaf Height 3

Siblings

5 6 Level 2

Child /

Offspring

7 Level 3

Trees

Theorem: Let , 0 be a rooted tree. Then

is irreflexive

is asymmetric

in , for all , and in .

Trees

Example: Let = 1 , 2 , 3 , , 10 and let

2 , 3 , 2 , 1 , 4 , 5 , 4 , 6 ,

=

5 , 8 , 6 , 7 , 4 , 2 , 7 , 9 , 7 , 10

-trees

Definition:

If is a positive integer, we say that a tree is an -

tree if every vertex has at most offspring.

A 2-tree is called a binary tree.

Definition:

If all vertices of , other than the leaves, have

exactly offspring, we say that is a complete

-tree.

A complete 2-tree is called a completed binary tree.

Subtrees

Let , 0 be a rooted tree on the set , and let

be a vertex of .

descendants, i.e., all vertices of that can be reached

by a path beginning at .

that is ( ).

edges that do not begin and end at any such vertex.

Subtrees

Theorem: If , 0 is a rooted tree and in , then

is also a rooted tree with root .

0

1 2 3

4 5

Subtrees

Theorem: If , 0 is a rooted tree and in , then

is also a rooted tree with root .

0

4 5

Exercises

Exercise 1: Determine if is a tree and, if it is, find the

root.

= , , , ,

= , , , , , , ,

= 1, 2, 3, 4, 5, 6

= 2,1 , 3,4 , 5,2 , 6,5 , 6,3

Exercises

Exercise 2: Consider the rooted tree , 0 .

1 2 3

4 5 6 7 8 9

11 12 13 14

10 15

Exercises

Exercise 2: Consider the rooted tree , 0 .

1. List all level-3 vertices

2. List all leaves

3. What are the siblings of 8?

4. What are the descendants of 3?

5. Compute 2

6. Compute 3

7. What is the height of , 0 ?

Labeled Trees

Example: Use a tree to denote the following algebraic

expression

3 2 + 2 3 +

+

- -

x - +

2 b b 2 3 b

Labeled Trees

Example: Use a tree to denote the following algebraic

expression

3 1 4 + 7 + 2 7 +

Labeled Trees

Positional -tree:

vertex from left to right with numbers 1,2, ,

missing

Labeled Trees

Example: positional 3-tree:

2 3

1 2 1 3

3 3

1 2 3

1 2 3

Labeled Trees

Example: positional 2-tree:

L R

R L R

R L L R

Tree Searching

Visiting

Performing appropriate tasks at a vertex will be

called visiting the vertex.

Tree search

The process of visiting each vertex of a tree in some

specific order will be called searching the tree or

performing a tree search.

Tree Searching

Algorithm PREORDER

Step 1: Visit

,

,

Tree Searching

Example 1 A

B H

C E I K

3 5 6 9 11

2 D F G 10 L

4 8 J

1 7

A B C D E F G H I J K L

Tree Searching

Example 2: + /

- +

/

a c

b

2 3 5

d e

1 7 8

6

4

- a b + c / d e

S. Turaev, CSC 1700 Discrete Mathematics 23

Tree Searching

Prefix or Polish form:

+ / ( = 6, = 4, = 5, = 2, = 2)

1. 6 4 + 5 / 2 2

2. 2 + 5 / 2 2 replacing 6 4 by 2 since 6 4 = 2

3. 2 + 5 1 replacing / 2 2 by 1 since 2/2 = 1

4. 2 6 replacing + 5 1 by 6 since 5 + 1 = 6

5. 12 replacing 2 6 by 12 since

2 6 = 12

S. Turaev, CSC 1700 Discrete Mathematics 24

Tree Searching

Algorithm INORDER

Tree Searching

Algorithm POSTORDER

Tree Searching

Example: Traveling the tree using INORDER and

POSTORDER

+ /

INORDER: + /

- + POSTORDER: / +

/

a c

b

d e

Tree Searching

Infix notation: Algebraic symbols lie between their

arguments

+ /

( ) ( + (/))

or

( ( + /))

Tree Searching

Postfix or reverse Polish:

/ + ( = 2, = 1, = 3, = 4, = 2)

1. 2 1 3 4 2 / +

S. Turaev, CSC 1700 Discrete Mathematics 29

Exercises

Show the result of performing a preorder search of the

tree

x

y z

t

s

u

Exercises

Show the result of performing an inorder search of the

tree

x

y z

t

s

u

Exercises

Show the result of performing a postorder search of the

tree

x

y z

t

s

u

Exercises

Show the result of performing preorder, inorder and

postorder searches of the tree

, , , , , , , , , , , ,

=

, , , , , , ,

Exercises

Show the result of performing preorder, inorder and

postorder searches of the tree

Exercises

Evaluate the expressions, which are given in Polish, or

prefix, notation

+ 3 4 7 2 12 3 6 4

3 2 4 3 + 15 2 6 3

Exercises

Evaluate the expressions, which are given in reverse

Polish, or postfix, notation

43254253

374 9652+

Exercises

Draw a binary tree whose preorder search produces

JBACDIHEGF

CATSANDDOGS

SEARCHING

TREEHOUSE

- twenty question , john T .pdfUploaded byJumrotul Mu'arofah
- Dror Bar-Natan and Zsuzsanna Dancso- Homomorphic Expansions for Knotted Trivalent Graphs- Fixing an AnomolyUploaded byGmonicon
- Binary TreeUploaded bymrbkiter
- [Universitext] Peter Morris (Auth.) - Introduction to Game Theory (1994, Springer-Verlag New York)Uploaded byJose Maria Lopez Belinchon
- AVL treesUploaded bySwarnali Sarkar
- TraversalUploaded byAnbarasan Periasamy
- daslides-cUploaded byAmanuel Wk
- GreedyUploaded byAarti Barve
- Binary Search TreeUploaded bySaranya Perumal
- Graph TheoryUploaded byprabhamaths
- Grade 11 Exam ReviewUploaded bykheartsgal
- Saharon Shelah and Joel Spencer- Can You Feel the Double JumpUploaded byHutsDM
- 1989-40Uploaded bySweetStupid Jeevadoss
- Binomial Theorem.pdfUploaded byprasenjit karan
- Combinatorial Geometry with Applications to Field Theory, Second Edition, graduate textbook in mathematics, by Linfan MaoUploaded byAnonymous 0U9j6BLllB
- Tutorial 5 SolUploaded byAli Alabid
- b11084-3Uploaded bySosacaustica Hidróxido de Sodio
- Frontiers of Computational Journalism - Columbia Journalism School Fall 2012 - Week 9: Social Network AnalysisUploaded byJonathan Stray
- 460-HeapDeapUploaded byDaniel Felipe
- CountingUploaded bybbscribed
- Practice Test QuestionsUploaded byErvica Badiatuzzahra
- BspTrees QuadUploaded byRahul Rana
- The Adjacency MatrixUploaded byronojoysengupta
- UntitledUploaded bySachin N Gudimani
- TErminos matematicosUploaded byAndres García
- Factorial - Combination and PermutationUploaded byKim Lanto
- dsgt_2006Uploaded byandhracolleges
- 8. Xi Binomial Theorem Remesh HssliveUploaded byShavik Sher
- AVL-01Uploaded byquytruyenkiep
- mathgen-1284749432Uploaded byDjordje Radic

- Carnot Heat EngineUploaded bySheraz Ali
- Food processing IndustryUploaded bySheraz Ali
- Industrial Alcohol ProductionUploaded bySheraz Ali
- Industrial Alcohol ProductionUploaded bySheraz Ali
- Origin of PetroleumUploaded bySheraz Ali
- Origin of PetroleumUploaded bySheraz Ali
- TP-Report.docxUploaded bySheraz Ali
- Faisal_Process Graduate CVUploaded bySheraz Ali
- Soap and detergents manufacturingUploaded bySheraz Ali
- Varnish.docxUploaded bySheraz Ali
- InterruptUploaded bySheraz Ali
- How to write Scientific Engineering Paper.docxUploaded bySheraz Ali
- Single Super PhosphateUploaded bySheraz Ali
- TypesOF_research.pdfUploaded byMariel Olarte
- Babar C++Uploaded bySheraz Ali
- Carnot Heat EngineUploaded bySheraz Ali
- Simulation flow sheet Model-2Uploaded bySheraz Ali
- Break.docxUploaded bySheraz Ali
- Break.docxUploaded bySheraz Ali
- Digital Fundamentals Chapter 4 - Thomas L. FloydUploaded byskphero
- Novel Report TGA TDAUploaded bySheraz Ali
- Plant Design Term ReportUploaded bySheraz Ali
- CS302 Finalterm Solved Mcq by MoaazUploaded byAqil Siddiqui
- Constitution of 1956Uploaded bySheraz Ali
- Constitution of 1973Uploaded bySheraz Ali
- Algorithm Types and ClassificationUploaded bySheraz Ali
- Processor Performance EnhancementUploaded bySheraz Ali
- Environmental impact assementUploaded bySheraz Ali
- Simulation flow sheet Model-1Uploaded bySheraz Ali
- Packed ColumnsUploaded bySheraz Ali

- Hybrid Recurrent Neural Networks: An Application to Phoneme ClassificationUploaded byrohitash
- GREPUploaded byirshad
- Two and a Half Black MenUploaded byRodney Ohebsion
- chapter 12 teacher skills practiceUploaded byapi-262088658
- ch28physicsloncap9helpUploaded byjonjones666
- Fast Convolution AlgorithmsUploaded byRogmary Dominguez
- Grape Leaf Disease Detection Using K-means Clustering AlgorithmUploaded byIRJET Journal
- 4. Sec-4 (Pavement Design Roads Network)Uploaded byHassan Tahir
- The Ultimate Value at RiskUploaded byDr. Jeff Lewis
- EE6301 DLC Unit 2 Part a Q&AUploaded byVigneswaran Vignesh
- Elmod6QuickStart Rel. 2Uploaded byLaksmana Angga Parsada
- 4363-114-IETMUploaded byyogesh_b_k
- Heat Transfer Modeling and Simulation of Mas at 1Uploaded bytomekzawistowski
- Verification Manual Indian CodesUploaded byArunkumar AK
- ANSYS Piping Application Users GuideUploaded bySuri Kens Michua
- Unit 2 Review (MPM2DG)Uploaded byFrederick Ding
- bfitUploaded bywaffle_copter
- Test Ch. 12 (The Gas Laws)Practice.docUploaded byliza1207
- 10. Mathematics - Ijmcar - Generalized Reverse Derivations on Prime RingUploaded byTJPRC Publications
- Slides Casarin Monte carloUploaded byKristen Fields
- Slugs AparicionUploaded byYesi Matos
- Book of AbstractUploaded bywal1547
- seeingthingsdifferentlymathsportfolio santaromanaUploaded byapi-306465805
- Savitzky (1964)Uploaded byCarolina Vertis
- Standing Waves on Strings!Uploaded byAtif Imam
- Laplace Transform - Final ExamUploaded bydatUPstudentdoe
- unit 9Uploaded byapi-268988549
- vol4no1-4_TiwariSUploaded bySandra Powers
- HandBook and Software for Plant Geneticists and BreedersUploaded byjlcoyac
- MBA 1st Semester SyllabusUploaded byVignesh RV