# History And Introduction Of Binary Trees English Language Essay

5/12/16 English Language Reference this

**Disclaimer:** This work has been submitted by a student. This is not an example of the work produced by our Essay Writing Service. You can view samples of our professional work here.

Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of UK Essays.

Tree is a data structure usually use in math concept can be seen as a graph. The data structure or graph are suited each other as the data structure does not only contain elements but the connection of the elements too. History of Tree was prevented by Cayley in 1857 (100 years before Malaysia got the independence). Cayley was the first man study about Tree then continues by Mckay. He discovers the vertices in database of tree into18 vertices and Royle maintains up to 20 vertices. Nowadays all their effort grant us to a lot of things we use the Tree concept in our daily live and the uses of Tree is very useful in science computer.

A Tree is a set of line segment with all of the elements is connected whether left or right. We specified it into binary tree which is the concept of single parent (root or parent nodes) with at least 1 child (child nodes). Further study on binary tree is a full binary tree which meant that every root must have two nodes located left and right of the root. The entire tree is a bipartite graph. The connection point is called fork and the segment is called branches.

That is a little bit about tree and we will learn more in next pages. Tree had become useful in our daily life. We can connect each data that we have to solve mathematic problems. We also had done a research on the application of binary tree in our daily life and their uses in science computer to develop well us as science computer student.

Binary Tree

Full Binary Tree

## TYPES OF BINARY TREE

There are several types of binary tree. Two of them are stated as previous page and here are other types of binary tree:

A rooted binary tree is a tree with a root node in which every node has at most two children.

A full binary tree (sometimes called as proper binary tree or 2-tree or strictly binary tree) is a tree in which every node other than the leaves has two children.

A perfect binary tree is a full binary tree in which all leaves are at the same depth or same level. (This is ambiguously also called a complete binary tree.)

A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.

An infinite complete binary tree is a tree with levels, where for each level d the number of existing nodes at level d is equal to 2d. The cardinal number of the set of all nodes is. The cardinal number of the set of all paths is. The infinite complete binary tree essentially describes the structure of the Cantor set; the unit interval on the real line (of cardinality) is the continuous image of the Cantor set; this tree is sometimes called the Cantor space.

A balanced binary tree is where the depth of all the leaves differs by at most 1. Balanced trees have a predictable depth (how many nodes are traversed from the root to a leaf, root counting as node 0 and subsequent as 1, 2, …, depth). This depth is equal to the integer part of log2 (n) where n is the number of nodes on the balanced tree. Example 1: balanced tree with 1 node, log2 (1) = 0 (depth = 0). Example 2: balanced tree with 3 nodes, log2 (3) = 1.59 (depth=1). Example 3: balanced tree with 5 nodes, log2 (5) = 2.32 (depth of tree is 2 nodes).

A rooted complete binary tree can be identified with a free magma.

A degenerate tree is a tree where for each parent node, there is only one associated child node. This means that in a performance measurement, the tree will behave like a linked list data structure.

## PROPERTIES OF BINARY TREE

After we had study the types of binary tree, now we need to study the properties for each types of binary tree. Perfect binary tree required this formula to find the number of nodes that is n = 2h + 1 âˆ’ 1 where h is the height of the tree and this formula n = 2L âˆ’ 1 where L is the number of leaf nodes in the tree. Nodes in Complete binary tree have a different formula that is minimum: n = 2h and maximum: n = 2h + 1 – 1 where h is the height of the tree. The number of NULL LINK is (n+1) and the leaf nodes in Complete binary tree is (n / 2). Non-empty binary tree have different formula n0 leaf nodes and n2 nodes of degree 2, n0 = n2 + 1. Thus n = n0 + n1 + n2 + n4 + n3 + n5 +…. + nB-1 + nB and to find B is, B = n – 1, n = 1 + 1*n1 + 2*n2 + 3*n3 + 4*n4 + … + B*nB, NOT include n0.

## TRAVERSAL

If one dimensional array was compared with data structures like link list, which have an official method of traversal, tree structures can be traversed in many ways. There three main steps that can be shown and the order of the binary tree. First of all is to perform defines the traversal type, next is to traversing to the left child node follow by right child node. This is the easiest method to describe a binary tree through recursion

## METHODS FIND TRAVERSAL IN BINARY TREES

There are several common orders in which nodes can be visited with their own advantages. Here a three main order in binary trees:

In-order: Left child, Root, Right child

Post-order: Left child, Right child, Root

Pre-order: Root, Left child, Right child

In-order, Pre-order and Post-order traversal visit each node in a tree by recursively visiting each node in the left and the right subtrees of the root. If the root node visited before its subtrees, this is pre-order, if after so it is post-order and if in between this is in-order.

Depth-First Traversal

This is one of the concepts to find the traversal of the tree. We always attempt to visit the node farthest from the root we attempt to forget too but, through depth first we does not need to remember all the nodes we have visited.

In Pre-order we should go through the root first then followed by left subtree and right subtree. But in In-order we will visit the left subtree first then we visit the root followed by right subtree. Lastly Post-order we start with subtree from the left followed with right then we will visit the root.

Breadth-first Traversal

Breadth-first traversal is which is opposite with depth-first traversal attempts to the closest nodes to the root. With this method a tree can traversed in level order, by going through from root to the lowest children.

Example of Breadth-first traversal

Preorder traversal sequence: F, B, A, D, C, E, G, I, H (root, left, right)

Inorder traversal sequence: A, B, C, D, E, F, G, H, I (left, root, right)

Postorder traversal sequence: A, C, E, D, B, H, I, G, F (left, right, root)

## BINARY TREE APPLIED IN SCIENCE COMPUTER

In computer science, binary tree can be applied such as in java, c/c++ programming, data structure and algorithms. In java, implementation is same in c/c++ programming, solution java is copying the solution in c/c++ and making the syntactic language. Almost every operation have two methods, a one-line method on the binary tree that starts the computation, and a recursive method that works on the node objects. For the lookup() operation, there is a binarytree.lookup() method that the client uses to start a lookup operation. Internal to the binarytree class, there is a private recursive lookup (node) method that implements the recursion down the node structure. This second, private recursive method is basically the same as the recursive C/C++ functions.

In binary tree for data structure, a linked list structure is not efficient when searching for a specific item as the node can only be accessed sequentially. The binary search algorithm suggests a data structure which can be implemented using dynamic storage and allows searching to be done efficiently.

## EXAMPLE IN JAVA

// BinaryTree.java

public class BinaryTree {

// Root node pointer. Will be null for an empty tree.

private Node root;

## /*

–Node–

The binary tree is built using this nested node class.

Each node stores one data element, and has left and right

sub-tree pointer which may be null.

The node is a “dumb” nested class — we just use it for

storage; it does not have any methods.

## */

private static class Node {

Node left;

Node right;

int data;

Node(int newData) {

left = null;

right = null;

data = newData;

## }

## }

## /**

Creates an empty binary tree — a null root pointer.

## */

public void BinaryTree() {

root = null;

## }

## /**

Returns true if the given target is in the binary tree.

Uses a recursive helper.

## */

public boolean lookup(int data) {

return(lookup(root, data));

## }

## /**

Recursive lookup — given a node, recur

down searching for the given data.

## */

private boolean lookup(Node node, int data) {

if (node==null) {

return(false);

## }

if (data==node.data) {

return(true);

## }

else if (data

return(lookup(node.left, data));

## }

else {

return(lookup(node.right, data));

## }

## }

## /**

Inserts the given data into the binary tree.

Uses a recursive helper.

## */

public void insert(int data) {

root = insert(root, data);

## }

## /**

Recursive insert — given a node pointer, recur down and

insert the given data into the tree. Returns the new

node pointer (the standard way to communicate

a changed pointer back to the caller). */

private Node insert(Node node, int data) {

if (node==null) {

node = new Node(data);

## }

else {

if (data <= node.data) {

node.left = insert(node.left, data);

## }

else {

node.right = insert(node.right, data);

## }

## }

return(node); // in any case, return the new pointer to the caller

## }

## BINARY TREE APPLIED IN DAILY LIFE

Binary tree can be applied in our life. This can be shown in competition schedule in sports, family flows, organizations and others. The tree showed the flows of an organization so we can know who or how an organization is flowed. Besides that, we can know the header in an organization, our relation in a family or our competitor in a sport. Others, we can position in an organization so that we not mistake or just estimate someone position in an organization. We also can deal with someone based on the position in an organization and can save our time for dealings.

## EXAMPLE

## CONCLUSION

We can conclude that binary tree a lot of usage in our life. The binary tree is applied not just in daily life but in computer system. This is because the usages of binary tree easy for the programmer to make a system. Other than that, the application of binary tree can be found in the computer science. In addition, we are pleased to see the chart and reduce errors during the program or enter into an agreement with an officer in an organization. Using the tree, we will know a person’s position in an organization or in sports.

If you need assistance with writing your essay, our professional essay writing service is here to help!

Find out more#### Cite This Work

To export a reference to this article please select a referencing style below:

## Related Services

View all### DMCA / Removal Request

If you are the original writer of this essay and no longer wish to have the essay published on the UK Essays website then please: