Monday, 16 March 2015

Revisiting Binary Trees

-D16, M03, Y15-

Howdy Hello and welcome back to the most fascinating blog out there! ehe...

So anyways, last week was less education-oriented due to a midterm test combined with the ongoing strike. Essentially, we revisited Binary Trees--particularly methods of insertion and deletion. These two methods require noticeably more work simply due to the need to recognize and deal with each possible case (e.g., if the node exists, if the data at that particular node is greater than or less than the data in question, if the node is a leaf, leads to only one other node, or is an internal node, and the like). Now some may ask, why bother with a multitude of cases when you can just go through all the nodes in a Binary Tree and grab the ones you want?
The answer is simple: going through all nodes in a Binary Tree is only feasible for a small amount of nodes. When confronted with a data structure consisting of millions of pieces of data, and that data is already nicely sorted (or can be sorted with ease), it is noticeably quicker and less work-intensive to search through only a few nodes to find the data-piece you want.

Now, concerning the idea of deletion. I may have touched on this before when I spoke about Linked Lists last week, so bear with me. When something is 'deleted' from a Binary Tree, this is equivalent to having cut the ties to that particular node of data and refastening the rest of the Binary Tree together. The 'deleted' node still exists--floating out there in the sea of binary--but it is simply no longer welcome in the BT club reachable via the Binary Tree. These outcasts floating nodes of data could potentially be a problem, taking up precious computer memory without contributing to the Cause to anything. However, Python--like any proper program--is capable of taking out the trash disposing of excess pieces of information without the user having to implement a function to delete the floating node from memory directly.

I have a feeling this indirect technique of deletion will become a key feature of other data structures in the future of my education. Thanks for reading!

No comments:

Post a Comment