Sunday, March 1, 2015

         We learned tree and binary search tree in class this week, and as I heard from my TA during the lab, it is actually one really useful data structure in the later year in computer science.
         This how tree works. We first define a class tree and create nodes and leafs which are instances under the first node of the tree. As we create more and more nodes and leafs, we can draw an image base on this data structure, and it looks really similar to a root of a plant. This data structure is useful because we can write a recursion method to search something from the tree and it is not too hard.
         However, the binary search tree is actually a much more useful data structure. It is similar to tree, but instead of having unlimitedly many children (nodes) or leafs under one node, we limit the maximum number of children of a node to be two and all child has to be comparable with each other. Most importantly, the value of the left hand side of the children has to be less than the value of the root, and the value of the right hand side children has to be greater than the root. By this layout, we can write a simple recursion method to search a value in the binary search tree, and it can shorten the number of comparison during the searching by a large factor. Therefore, it is an extremely efficient data structure to use.

         After I realize the importance of this data structure, I spent quite a bit of time to understand the structure and asked for lots of help form the TA during the lab. Because of this, I feel pretty confident for writing the data structure tree, and I think this is also a good habit for studying computer science. Therefore, I will try keeping this study habit for the rest of the semester.  

No comments:

Post a Comment