0% found this document useful (0 votes)
29 views

Rooted Trees - 19cse1030

Rooted trees are a special type of directed trees that have a unique root vertex with in-degree of 0, and all other vertices have in-degree of 1 or more. Key terminology includes child/parent, root, leaf/terminal, branch/internal, level, and subtree. Ordered rooted trees assign alphabetical labels to vertices based on their level from the root. Complete binary trees require each vertex except leaves to have exactly two children. Polish notation writes mathematical expressions without parentheses by listing operands before operators.

Uploaded by

SHREYA SHANKE
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Rooted Trees - 19cse1030

Rooted trees are a special type of directed trees that have a unique root vertex with in-degree of 0, and all other vertices have in-degree of 1 or more. Key terminology includes child/parent, root, leaf/terminal, branch/internal, level, and subtree. Ordered rooted trees assign alphabetical labels to vertices based on their level from the root. Complete binary trees require each vertex except leaves to have exactly two children. Polish notation writes mathematical expressions without parentheses by listing operands before operators.

Uploaded by

SHREYA SHANKE
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

ROOTED TREES

{ PRESENTATION BY : -

Group 8

19CSE1028 – Sanjana Yadav


19CSE1029 – Sarah Dias Baretto
19CSE1030 – Shreya S. Shanke
INTRODUCTION

DIRECTED TREES
• If G is a directed graph, then G is called a directed tree if the undirected
graph is associated with G is a tree.

ROOTED TREES
• Rooted Trees are a special type of directed trees.

• When G is a directed tree, G is called a rooted tree if there is a unique


vertex r, called the root, in G with the in degree of r =id(r) = 0 and for all
the other vertices v, the in degree of v =id(v) = 0.
 The tree in the first part is directed but not rooted.

 The tree in the second part is rooted with root r.

 We draw rooted trees with directions going from the upper level to
the lower level, so that the arrows aren't needed.
TERMINOLOGIES
 CHILD & PARENT

We call s a child of n, and we call n the parent


of s. So, Vertices w, y, z are considered as
descendants of s, n, r while s, n, r are called
ancestors of w, y, z.

 ROOT

The initial vertex that does not have a parent.


Here r is the root.

 LEAF/ TERMINAL VERTEX

A vertex without degree 0 in a rooted tree. Here, the


vertices u, v, x, y, z are leaves.

 BRANCH NODES / INTERNAL VERTICES

All the other vertices.


 LEVEL

Level = Length of the edge of a path from


root to destination.
Consider the vertex s in this rooted tree. The
path from the root r to s is of length 2. So, s is
at level 2.

 SIBLINGS

Two vertices with a common parent are


called siblings.
Such is the case for vertices q & s, whose
common parent is vertex n.

 SUBTREE

w, y, z
ORDERED ROOTED TREE
 In the tree T as shown below in the figure, the edges or branches leaving each
internal vertex are ordered from left to right. Hence, such a tree T is called an
ordered rooted tree.
 Consequently, each vertex in T, other than the root has a label the
form a1.a2.a3…an if and only if that vertex has level number n.
this is known as the universal address system

 Since this represents the alphabetical order in a dictionary,


the order is called lexicographic or dictionary order.
COMPLETE BINARY TREE
 This is an application of a rooted tree in the
study of computer science.
 A rooted tree is a binary rooted tree if for
each vertex v , od(v) = 0, 1 or 2, i.e., if v has at
most 2 children.
 If od(v) = 0 or 2 for all v E V, then the rooted
tree is called a complete binary tree.
 Such a tree can represent a binary operation as
shown in the figure.
 To avoid confusion when dealing with a non
commutative operation o we label the root as
o and required result to be a o b, where a is the
left child and b is the right child of the root.
EXAMPLE
Here we need to
construct a
complete binary
tree which can
be evaluated to
the given
expression
POLISH NOTATION
 Consider t + (uv) / (w + x - yz). The same is written in the form :
t + (u * v) / (w + x – y z).

When the computer evaluates this expression, it performs the binary


operations within each parenthesized part according to a hierarchy of
operations. For the computer to evaluate this expression, it must
somehow scan the expression. Instead of scanning back and forth
continuously, the machine converts the expression into a notation that is
independent of parentheses. This is known as Polish Notation named
after the Polish logician Jan Lukasiewicz.

Here the infix notation a o b for a binary operation o becomes o ab , the


prefix or Polish notation. The evaluation proceeds from right to left. The
expression can be rewritten without parentheses as :

+ t / * uv + w - x yz.
EXAMPLE : In the expression : t + (u * v) / (w + x – y z).

Let t = 4, u = 2, v = 3, w = 1, x = 9, y = 2, z = 3 Then, the


following steps will be taken to evaluate the expression.

The use of Polish Notation is important for compilation of


computer programs.

You might also like