Sie sind auf Seite 1von 16

INFORMATION SEARCH AND ANALYSIS SKILLS

(ISAS)

“ Binary Tree “

Group : V
Name : Davi Rama Fadillah
Mikyal Nazma Setianis
Syahrul Husna

Faculty : Devi Afrillia Sinikite, A.Md

Class : 2SC3

Continuing Education Program Center for Computing and Information Technology

Faculty of Engineering, University of Indonesia

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.

Depok, May 2019

Author

i
Table of Contents

PREFACE ................................................................................................................................... i

Table of Contents .......................................................................................................................ii

Table of Figures ....................................................................................................................... iii

CHAPTER I ............................................................................................................................... 1

I.1 Background ....................................................................................................................... 1

I.2 Writing Objective.............................................................................................................. 1

I.3 Problem Domain ............................................................................................................... 1

I.4 Writing Methodology........................................................................................................ 2

I.5 Writing Framework. .......................................................................................................... 2

CHAPTER II.............................................................................................................................. 3

II.1 Algorithm......................................................................................................................... 3

II.2 Binary Tree ...................................................................................................................... 3

II.3 Tree .................................................................................................................................. 4

II.3 Tree Traversal .................................................................................................................. 5

CHAPTER III ............................................................................................................................ 6

III.1 Tree Traversal Algorithm ............................................................................................... 6

III.2 Tree Traversal Java Implementation .............................................................................. 9

III.3 The Binary Tree Map ................................................................................................... 11

CHAPTER IV .......................................................................................................................... 12

IV.1 Conclusion ................................................................................................................... 12

IV.2 Solution ........................................................................................................................ 12

Bibliography ............................................................................................................................ 13

ii
Table of Figures

Figure 2.1 Tree Graph ............................................................................................................ 4

Figure 3.1 Preorder Traversal................................................................................................. 6

Figure 3.2 Inorder Traversal................................................................................................... 7

Figure 3.3 Postorder Traversal ............................................................................................... 8

Figure 3.4 Traversal Java Implementation ............................................................................. 9

Figure 3.5 Preorder Traversal................................................................................................. 9

Figure 3.6 Inorder Traversal................................................................................................... 9

Figure 3.7 Postorder Traversal ............................................................................................... 9

Figure 3.8 Method ................................................................................................................ 10

Figure 3.9 Output ................................................................................................................. 10

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.

1.2 Writing Objective

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.3 Problem Domain

Sufficiently understanding about implementation of features that is used in binary


tree.

1
2

1.4 Writing Methodology

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.

I.5 Writing Framework

• 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.

• CHAPTER III Problem Analysis


Chapter 3 consisted of:

 Tree Traversals Algorithm,


 Tree Traversals Implementation,
 The Binary Tree Map.

• CHAPTER IV Conclusion and Suggestion


Chapter 4 consisted of the conclusion and suggestions made in the setting up of
the ISAS.
CHAPTER II

BASIC THEORY

II.1 Algorithm

An algorithm is a systematic method of solving a problem. It is commonly used for


data processing, calculation, other related computer, and mathematical operations. An
algorithm is also used to manipulate data in various ways, such as inserting a new data
item, searching for a particular item or sorting an item. Algorithms can be expressed in
many kinds of notation, including natural languages, pseudocode, flowcharts, drakon-
charts, programming languages or control tables.

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.

II.2 Binary Tree

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

Main applications of trees include:


1. Manipulate hierarchical data.
2. Make information easy to search (see tree traversal).
3. Manipulate sorted lists of data.
4. As a workflow for compositing digital images for visual effects.
5. Router algorithms
6. Form of a multi-stage decision-making (see business chess).

II.3 Tree

Figure 2.1 Tree Graph


(https://www.gatevidyalay.com/tree-data-structure-tree-terminology/)

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

II.4 Various Tree Traversals

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

Inorder traversal gives nodes in non-decreasing order. To get nodes of BST


in non-increasing order, a variation of Inorder traversal where Inorder traversal
reversed can be used.

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

III.1 Tree Traversal Algorithm

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

Figure 3.1 Preorder Traversal


(https://www.tutorialspoint.com/data_structures_algorithms/tree_traversal.htm)

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.

We start from A, and following in-order traversal, we move to its left


subtree B. B is also traversed in-order. The process goes on until all the nodes
are visited. The output of inorder traversal of this tree will be −

D→B→E→A→F→C→G

Figure 3.2 Inorder Traversal


(https://www.tutorialspoint.com/data_structures_algorithms/tree_traversal.htm)
8

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

Figure 3.3 Postorder Traversal


(https://www.tutorialspoint.com/data_structures_algorithms/tree_traversal.htm)
9

III.2 Tree Traversals Java Implementation

Figure 3.4 Traversal Java Implementation

Figure 3.5 Preorder Traversal Method

Figure 3.6 Inorder Traversal Method

Figure 3.7 Postorder Traversal Method


10

Figure 3.8 Method

Figure 3.9 Output


11

III.3 The Binary Tree Map

Figure 3.10 Map

The result of PreOrder traversal tree is : A B D G H E I C F J.


The result of PostOrder traversal tree is : G H D I E B J F C A.
The result of InOrder traversal tree is : G D H B I E A F J C.
CHAPTER IV

CONCLUSION AND SUGGESTION


IV.1 Conclusion

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

Das könnte Ihnen auch gefallen