Articles

TREE

In Materi, Struktrur Data on January 5, 2011 by khalifrinaldi

Definition TREE
• It is a form of non-linear data structure
• A collection of elements one of which is called Roots and other residual elements called nodes

actually what is the use of this tree data structure?
utility tree are:
• Used to describe a relationship that is hierarchy, such as:
-organization structure
Classification-tree / genealogy
Syntax-tree / expression tree
1).
Example of a hierarchy of relationships
• Organizational structure

• expression tree for the arithmetic expression

((6 – (12 – (3 +7 )))/( 1 +0) +2) * (2 * (3 +1))

preorder :  * + a / b  cd * e f (prefix)

inordera + b / c * de * f (infix)

postordera b c / + d e f * – * (postfix)

to infix traversal
solution algorithm is:

Algorithm infix (val tree <tree pointer>)

if (tree not empty)

if (tree→token is an operand)

print (tree → token)

else

print (open parenthesis)

infix (tree →left)

print (tree →token)

infix (tree →right)

print (close parenthesis)

end if

end if

return

end infix
notasi posfix

Leave a comment

Design a site like this with WordPress.com
Get started