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

Introduction To Trees

This document provides an introduction to trees. It defines a tree as a connected acyclic graph. Key definitions for trees include: root node, child node, parent node, leaf node, depth/height of a node, height of a tree, siblings, ancestors, descendants, subtree, and tree arity (whether a tree is n-ary or binary). Examples are provided to illustrate these tree definitions and concepts.

Uploaded by

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

Introduction To Trees

This document provides an introduction to trees. It defines a tree as a connected acyclic graph. Key definitions for trees include: root node, child node, parent node, leaf node, depth/height of a node, height of a tree, siblings, ancestors, descendants, subtree, and tree arity (whether a tree is n-ary or binary). Examples are provided to illustrate these tree definitions and concepts.

Uploaded by

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

Introduction to Trees

Lecture 16

1107186 Estrutura de Dados Turma


Prof. Christian Azambuja Pagot
CI / UFPB
Universidade Federal da Paraba
Centro de Informtica

02

What is a Tree?

In graph theory, a tree is defined as a


connected acyclic graph.
Example:
4

Node

2
1

Universidade Federal da Paraba


Centro de Informtica

Edge

However, one such


graph may generate
different tree
data structures!

What is a Tree?

In graph theory, a tree is defined as a


connected acyclic graph.
Root node
Example:

4
4
1

2
1

5
4

Universidade Federal da Paraba


Centro de Informtica

What is a Tree?

In graph theory, a tree is defined as a


connected acyclic graph.
Example:

Root node
1

4
2
4
1

Universidade Federal da Paraba


Centro de Informtica

Definitions

Path Length

Equal to the path length to the root.

Height of a Node

Depth of a Node

Number of edges on a path.

Equal to the path length from the


node to its deepest descendant.

Height of a Tree

Equal to the height of the root.


5

Universidade Federal da Paraba


Centro de Informtica

Definitions

Child Node

Parent Node

Each node can have n


child nodes.
It is unique for each
node.
The root does not have
parent node.

Universidade Federal da Paraba


Centro de Informtica

Definitions

Leaf Node

Nodes with the same

parent.

Ancestors

Siblings

Has no child node.

All nodes on the path to the root.

Descendants of a node n

All nodes that share n as an


ancestor.

Universidade Federal da Paraba


Centro de Informtica

Definitions

Subtree

Tree formed by a node


and all its descendants.
3

Universidade Federal da Paraba


Centro de Informtica

Definitions

Tree Arity

n-ary.
Binary.

n-ary tree
Universidade Federal da Paraba
Centro de Informtica

binary tree
9

You might also like