Beruflich Dokumente
Kultur Dokumente
(ISAS)
“ Binary Tree “
Group : V
Name : Davi Rama Fadillah
Mikyal Nazma Setianis
Syahrul Husna
Class : 2SC3
2019
PREFACE
Thank you, the writer wishes to God the Almighty for His blessings. We can complete
this ISAS assignment both in the form of presentation and paper in a timely manner. Not
forgetting thanks especially for the faculty of Ms. Devi Afrillia Sinikite, A.Md and other
faculties who always support. Thank you also to fellow students, who have supported, and
thank you for being fellow workers in the education at CCIT-FTUI, and thank you for our
family to help and support us to complete this assignment.
The ISAS paper entitled “Binary Tree” the author submits as the ISAS assignment in
2019.
The author hope this paper can be useful for everyone to get more information and
knowledge. The author recognize that this paper is away from perfect. Therefore, the author
really expect conclusion and suggestion from readers who are constructive in order to perfect
this paper.
Finally, hopefully this paper can provide many benefits for the reader.
Author
i
Table of Contents
PREFACE ................................................................................................................................... i
CHAPTER I ............................................................................................................................... 1
CHAPTER II.............................................................................................................................. 3
II.1 Algorithm......................................................................................................................... 3
CHAPTER IV .......................................................................................................................... 12
Bibliography ............................................................................................................................ 13
ii
Table of Figures
iii
CHAPTER I
INTRODUCTION
1.1 Background
Most people have the perception of computers as very powerful devices where human
life have been trusted to depend on it. Computers can be operated very quickly because
they are powered by the existence of programs. Programming is what gives miracle to
computers. A program is a set of directions that tells the computer anything that needs to
be done, as a medium for humans to communicate with their computers. Programs give
millions of commands that is run consistently and quickly by the computer.
Algorithm is a working method that is implemented on a computer to process an input
data to produce output data. Data needs to be structured so that a simple algorithm can
be obtained. The algorithm cannot be separated from the data structure chosen in
representing the problem data.
And current authors wish to discuss one implementation used in the binary tree data
structure. Such as tree traversals features that have function in processing data.
This paper sole objective is to explain, clarify, and justify the existence and use of
Binary Tree, the tree traversals, and how they work.
1
2
The method of writing this paper is by using the methods of literature study. We get
our references from books and internet, then collect the materials to discuss until we get
the best conclusion for this research.
• CHAPTER I Introduction
Chapter 1 mainly discuss the background of the problem, Writing Objective,
Problem Domain, the method of writing that is used as the system of writing,
and Writing Framework.
• CHAPTER II
Chapter 2 mainly discuss description about algorithm, basic understanding of
Binary Tree, the definition about the Tree itself, and about various tree
traversals.
BASIC THEORY
II.1 Algorithm
Algorithms are not limited to computers. They are like a set of step-by-step
instructions or even a recipe, containing things you need, steps to do, the order to do
them, conditions to look for, and expected results.
A binary tree is a tree data structure where each node has up to two child nodes,
creating the branches of the tree. The two children are usually called the left and right
nodes. Parent nodes are nodes with children, while child nodes may include references
to their parents.
If every node in a tree can have at most two children, the tree is called a binary tree.
In this chapter, we will focus on binary trees because they are the simplest and the most
common data structures used.
The two children of each node in a binary tree are called the left child and the right
child, corresponding to their positions when you draw a picture of a tree, A node in a
binary tree doesn’t necessarily have the maximum of two children; it may have only a
left child, or only a right child, or it can have no children at all .
3
4
II.3 Tree
A tree consists of nodes connected by edges. As depicted in figure 2.1 the nodes are
represented as circles, and the edges are the lines connecting the circles. A tree is
actually an instance of a more general category called a graph.
In computer programs, nodes often represent such entities as people, car parts,
airline reservations, and so on—in other words, the typical items we store in any kind
of data structure.
The lines (edges) between the nodes represent the way the nodes are related.
Roughly speaking, the lines represent convenience: It’s easy (and fast) for a program
to get from one node to another if there is a line connecting them. In fact, the only way
to get from node to node is to follow a path along the lines.
5
Traversal is a process to visit all the nodes of a tree and may print their values too.
Because all nodes are connected via edges (links) we always start from the root (head)
node. The following is a variety of tree traversals, among others :
1. Preorder Traversal
It is used to explore all the root before inspecting any leaves. Preorder
traversal is also used to create a copy of the tree and to get prefix expression
on of an expression tree.
2. Inorder Traversal
3. Postorder Traversal
It used to explore all the leaves before any nodes. Postorder traversal is also
useful to get the postfix expression of an expression tree.
CHAPTER III
SYSTEM ANALYSIS
1. Preorder Traversal
In this traversal method, the root node is visited first, then the left subtree
and finally the right subtree.
Start from A, and following pre-order traversal, we first visit A itself and
then move to its left subtree B. B is also traversed pre-order. The process goes
on until all the nodes are visited. The output of pre-order traversal of this tree
will be −
A→B→D→E→C→F→G
6
7
2. Inorder Traversal
In this traversal method, the left subtree is visited first, then the root and later
the right sub-tree. We should always remember that every node may represent
a subtree itself. the output will produce sorted key values in an ascending order.
D→B→E→A→F→C→G
3. Postorder Traversal
In this traversal method, the root node is visited last, hence the name. First
we traverse the left subtree, then the right subtree and finally the root node.
We start from A, and following Post-order traversal, we first visit the left
subtree B. B is also traversed post-order. The process goes on until all the nodes
are visited. The output of post-order traversal of this tree will be −
D→E→B→F→G→C→A
Binary tree is a very powerful (but not perfect) data structure to have in your
programming tool belt. Then, binary tree has the good features such tree traversals
(preorder, inorder, postorder) to process data.
IV.2 Suggestion
12