- Abstract Data Type, Tree
- Binary Search Tree
- LinkedList
Trees are a data type with a value and a set/list of children such that parent references the child, but the child does not have any data stored for its parent. These abstract data type trees are incredibly powerful for traversing, finding data, and also show the data structure that recursion operates in, such that one value depends on multiple branches of values that depend on other branches of values. A disorganized abstract tree such as:
Seems to have relatively little use, other than providing a data-integral structure for recursive operations. However, once we began learning about binary trees, a lot of things I've been doing have clicked. I work with MySQL and PHP on a daily basis and often have to worry about optimization (this includes partitioning literally millions of search rows, complicated JOINS, CASES, etc.) , and often need to deal with indexing data, BTREE, Fenwick trees, database engines, etc. I didn't really understand much, but I've always heard MySQL (which is renowned for its incredible speed) SELECT statement on BTREE indexed runs in log(n) time. It was not until we learnt about trees and BST that I made the connection from on why BTREE (Binary Tree) index runs in log(n) time almost immediately:
A BTRE, or BST, organizes data such that the left side of a node is always less than that node value and the right side is always more. While I'm not entirely sure how MySQL organizes its BTREE index, it makes sense behind how it works. By organizing data like this, we can continually eliminate half of the tree as we traverse it, thus running in log(n) time on average cases, explaining partially why MySQL SELECT statement is so fast:
http://en.wikipedia.org/wiki/Fenwick_tree
Which is a type of BTREE indexed data tree that is used to calculate very quickly a continually and cumulative increment of a sequence (useful for calculating likes on posts and for random-weighted select statements). The last data structure was for LinkedLists which actually finds a lot of use in comments on posts and other structures on websites:
LinkedLists allows for very quick insertion and deletion (as you just slice a reference out), but have slow indexing and random-access as well as other uses arrays may be used for.
With learning these applicable data structures beyond just the exam and term tests, I am quite excited to see what we will continue to learn and the next years of computer science.




No comments:
Post a Comment