We use cookies to give you the best experience possible. By continuing we’ll assume you’re on board with our cookie policy

See Pricing

What's Your Topic?

Hire a Professional Writer Now

The input space is limited by 250 symbols

What's Your Deadline?

Choose 3 Hours or More.
2/4 steps

How Many Pages?

3/4 steps

Sign Up and See Pricing

"You must agree to out terms of services and privacy policy"
Get Offer

Binary Search Tree Investigation

Hire a Professional Writer Now

The input space is limited by 250 symbols

Deadline:2 days left
"You must agree to out terms of services and privacy policy"
Write my paper

Welcome to my commentary about trees. I will try to make this as insightful as possible, due to my interest in both the area of data structures in Mathematics and Computer Science. The reason why we use trees in mathematics is for organizing data into a structured manner and to link each of the pieces of data (from now on referred to as Objects), together. The advantage of using a tree structure is due to it’s ability of holding continuous real-world data, which can be added and deleted at any time.

Don't use plagiarized sources. Get Your Custom Essay on
Binary Search Tree Investigation
Just from $13,9/Page
Get custom paper

In other words, strictly for scientific purposes, trees are ideal manners of organizing data in a sequential, structured manner, and at the same time allowing for the structure to grow and shrink in real-time. There are four required steps/procedures to be taken before the “tree” can work as an efficient representation of a certain data structure: Step One: data must be “sorted” in a certain manner. This means, that the data may be sorted in degree of polynomials, by the number of their significant figures (floating point calculations), in order of ascending or descending numerical value (from lowest to highest or reverse order), and other.

In computer science, a strict algorithm is used as a means of maintaining the efficiency of the data structure (i. e. if it contains continuous data or any form of decimal number set where “precision matters” we want the precision of the numbers to be kept as they are once they are sorted. Therefore, the binary search is implemented. Function of the binary search: 1) Considering that the structure is already sorted (if not we need to do so)the goal of the binary search is to find a location within the “tree” called the ey, and ensure, that there is space for it if something were to be overwritten on it. The binary search functions by looking through the whole length of the data structure (it finds the range between the maximum and minimum, as well as the average between the highest and lowest values and divides them by two to get the midpoint of the values, the middle component). If the value being searched for is higher than the midpoint, then it goes into to the middle of the lower quartile of the array and looks again.

If the middle components’s stored value was too low, it will go to the upper quartile of the array instead. The search keeps repeating this ‘split the remainder’ step until it finds the “key (the value you want) and if it misses it, it will simply return -1, knowing that that value that we searched for doesn’t exist within the specified length of the array. On the other hand, if A > B works, within a binary search tree, according to the boolean logic that it is built upon, then if A>B then B>A must be also true, because of the “recursive” nature of the structure of the binary tree in itself.

And so, the “reverse algorithmically functioning search” is the sister of the binary search, and every binary tree must be able to handle both types of searches, in order to be effectively called “a tree. ” 2) The Recursive Binary Search will “call itself” until it runs out of places to look for the key. It takes in a data set and compares the key (a specific value we are looking to be found in this data set) to the mid element in the data structure.

If the value we are looking for is greater than the mid, then we look in the upper portion of the data structure, otherwise, if the key is less than it will look in the lower quartile of the data set, and it will keep doing so until either, it is found and returns positive 1, or if it isn’t found it returns -1. The idea is the same, to keep the search to be clear & efficient, especially, since we don’t want to waste a lot of memory on computers. When a search is done, we can move on to finding a place WHERE to place the structure for the tree to exist. This will be done by implementing modulus division.

Step Two: Modulus Division Next, the “modulus division” or modulo operation takes place, which is necessary for finding (this is referred to as the hashValue in computer science) . We use modulo operation, because before we can create the binary tree naturally because we need to make sure we have enough memory reserved for it. And so we implement the hashValue as a means of always having a place in memory where additional data can be stored in an archive. And so we find the hashValue in the named data structure containing say 4 letters: ‘A’’D’A’M’ – each with an individual ASCII character which has a value in computer language.

Implementing modulus division, we add A, D, A, and M together so 65 + 68 + 65 + 115 = 226. 6 => 7 rounded up. This will be 2227 amount of space that can be reserved, and where in memory, will be located by something else called the RAF (which is not our concern,since this isn’t about computer science). As another explanation suggests: A typical PC (as of 2008) might have a gigabyte of available memory, meaning that hash values of up to 30 bits could be accommodated. However, there are many applications that can get by with much less.

For example, when mapping character strings between upper and lower case, one can use the binary encoding of each character, interpreted as an integer, to index a table that gives the alternative form of that character (“A” for “a”, “8” for “8”, etc. ). If each character is stored in 8 bits (as is ASCII, the table has only 28 = 256 entries; in the case of Unicode characters, the table would have 17? 216 = 1114112 entries. A real life implication is used in to map two-letter country codes like “us” or “za” to country names (262=676 table entries), 5-digit zip codes like 13083 to city names (100000 entries), etc.

Invalid data values (such as the country code “xx” or the zip code 00000) may be left undefined in the table, or mapped to some appropriate “null” value. Step Three: Implementing Boolean Logic As earlier referred to with Boolean logic, when we talk about modulus operation, it either is or it isn’t – black & white, on and off, or 0 or 1. The outcome, however, is always true in boolean logic because something “always” happens, one way or another. This means there are two possible choices for the remainder, one negative and the other positive, and there are also two possible choices for the quotient.

Usually, in number theory, the positive remainder is always chosen, but programming languages choose depending on the language and the signs of a and n. Modulo operations might be implemented such that a division with a remainder is calculated each time. In this way, the hashValue is found, and thus it serves its purpose to find the “remainder Further examples of Modulo operation, concerning boolean logic in mathematics: Stating that x belongs to the integers (Z), If x % 2n == x & (2n – 1) is true then the following below are true… x % 2 == x & 1 x % 4 == x & 3 % 8 == x & 7 And so on. Step Four: Creating a branch within the tree, and Deleting a Branch Naturally, given that we are talking of a data structure of linked objects, the place (where all the links of the individual objects originate from) is important to know, particularly when data within the tree is to be edited, removed or added. Construction of the tree: Java Notes: root is a “treeNode” type. Similar to a linkedList class, and here we will “link together” the “the TreeNodes” of the TreeNode class. And finally we see something is happening.

Three constructors, we just send one argument which is an empty string and we look a the treenode that takes in eobject initValue each node had data and the next and what we linked was these nodes together, left and right needs to be set so we know where they point to. Kathy will point in one direction to bob, and in one direction to Madi. TreeNode type in treenodeClass = self-referential variables. Unfortunately, the hardest part of the binary tree is that it is not pointing left or right, and the binary tree is so “bareboned. and So, now we look at the AddNode Class, and because AddNode is the bt. AddNode class and so we can add the branches. Written Explanation: Now that the following conditions have been met: •Memory has been reserved for using data structures organized in a sequential manner •Data is organized and sorted •Modulus division has been used as a means of always having extra memory and having space available organized for the creation of a “tree. ” Java coding is used to create the binary tree.

The root is stabilized using Java Language, and from there, “tree branches are created” using logic. We do so by “inserting” values seeing if they are greater than or less than the “root” which has been created in a java-enabled program. Insertion begins as a search would begin; if the root is not equal to the value, we search the left or right branches of the tree. Eventually, we will reach an external node and add the value as its right or left “inherited” child, possessing the qualities of the “root,” however, the information held within the node remains intact.

The “value” held by the node is also a determining factor of where it will be placed within the binary tree’s branches. As stated before, we examine the root and recursively insert the new node to the left branch if the new value is less than the root, or the right branch if the new value is greater than or equal to the root. A functioning tree is identified by having met the following conditions: •The left branch of a node contains only nodes with keys less than the node’s key. The right branch of a node contains only nodes with keys greater than or equal to the node’s key. •Both the left and right branches must also capable of expanding the binary search tree, as opposed to just holding “null” wherever there is no value there yet. Step Five: Traversal Traversal and thus, manipulation of the data is concerned with the method of recursion, wherein, a trace is made from the “root destination” or “mother branch of the tree” to a destination within the tree The probability of each traversal must be 100% of finding the destination it wants to find.

If the probability were not 100% then the data within the tree would not have been properly linked, and so the data structure would not be intact! Subconsciously, while traversing through the tree, whether we are dealing with the PostOrder, or PreOrder method, we check the intactness of the tree itself, for this reason, once we know that a tree traversal is successful, we may tree the tree as a secure, fail-proof system of presenting our data within an encapsulated data structure. Let us use a diagram that we created, in class, (without java code) to understand how branches are traversed within the tree:

Diagram: The PreOrder method works by searching for the root which is 7, and each time, as it goes through it will compare whether the value it is dealing with is greater than or less than the root, and the boolean logic conditioning will determine which direction and which branch the traversal goes through first! PreOrder will traverse the left part first: 7,1,0 then it needs to backtrack and finish off the right branch, so it goes to 3, now is 3 less than 7? Yes, and where did we start traversing? To the left of the branch! So, because the boolean logic shows that indeed 3

Cite this Binary Search Tree Investigation

Binary Search Tree Investigation. (2018, Jul 27). Retrieved from https://graduateway.com/binary-search-tree-investigation/

Show less
  • Use multiple resourses when assembling your essay
  • Get help form professional writers when not sure you can do it yourself
  • Use Plagiarism Checker to double check your essay
  • Do not copy and paste free to download essays
Get plagiarism free essay

Search for essay samples now

Haven't found the Essay You Want?

Get my paper now

For Only $13.90/page