TREES AND BINARY TREES - PowerPoint PPT Presentation

About This Presentation
Title:

TREES AND BINARY TREES

Description:

Definitions. Parent- node that has successor nodes. Child- node that has ... Using the binary tree's root, left subtree, and right subtree, it is easy to ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 12
Provided by: matthew418
Learn more at: http://www.cs.loyola.edu
Category:
Tags: and | binary | trees | definitions | root | word

less

Transcript and Presenter's Notes

Title: TREES AND BINARY TREES


1
TREES AND BINARY TREES
By Matthew Greer
2
What is a Tree?
In computer science, trees are very important
figures that make sorting and finding data
easier. Programs contain a great amount of
information. In order to provide for greater
efficiency, trees create simpler, shorter paths
to the required data.
3
ALGORITHMS
In order to better understand the basic need for
trees, one must first look into the word
algorithm. An algorithm is a set of directions
and steps that leads to an end. They can be both
very simple or highly complex. In our daily
lives, we use algorithms. Something such as
getting ready to go to school or making lunch can
result in a number of steps in an algorithm.
Computer science uses algorithms to run
programs. In order for a program to work, the
steps need to be very specific and ordered.
Trees are used to make algorithms run quicker.
4
Breaking Down the Tree
Trees in computer science are much the same as a
family tree. They start from the top and move
their way down. As a whole, trees are broken
down into elements called nodes and the
connectors that connect them.
Node
Connector
An important aspect of the tree is the degree of
each node. The degree is the number of branches
connected to each node. Outdegree branches are
the ones which go away from the node. Indegree
branches are the ones which go toward the node.
5
Breaking Down the Tree
(Continued)
This diagram is more complex than the previous
one.
The root is the first node from the top. It has
an indegree of 0.
The leaves are the nodes which have an outdegree
of 0.
Other nodes are known as internal nodes.
6
Definitions
Parent- node that has successor nodes
Child- node that has predecessor nodes
Siblings- nodes that have same parent node
7
Binary Trees
In order to first define a binary tree, subtrees
must be defined. A subtree is simply any
connected grouping below the root.
Binary trees only can have a maximum of two
subtrees. The great part about binary trees is
that they are easier to be utilized. Both their
height and width can be predicted using set
formulas.
8
The Height and Balance of Binary Trees
In the height formula for binary trees, the
maximum height can be predicted using the formula
NHmax, in which N is simply the number of nodes.
The balance of a binary tree is found by taking
the height of the left and right sides of the
tree and finding the difference. BHL-HR.
The maximum height in the above diagram would be
eight. The balance is 4-3 1.
9
BINARY TREE TRAVERSALS
A binary tree traversal is a sequence in which
each node is gone through only once. These
traversals are broken up into depth-first
traversals and breadth-first traversals
Depth traversals are split up into different
categories. Using the binary trees root, left
subtree, and right subtree, it is easy to
understand this processes. Preorder traversals
puts the root first, the left subtree second, and
the right subtree last. Inorder traversals start
with the left subtree and make their way in a
clockwise direction. Postorder traversals place
the left subtree first as well, but instead moves
in a counterclockwise direction.
Breadth traversals are when the sequence goes
along each level before proceeding to the next
10
Expression Trees
An important application used through the binary
tree is called an expression tree. Expression
trees are made of a series of tokens, which act
as either operators or operands. These trees
follow a certain token sequence, using the
different rules implied in the binary tree.
Expression trees uses different processes to
calculate and utilize information
11
THE END
Write a Comment
User Comments (0)
About PowerShow.com