2014年3月22日土曜日

Week9 
BSTs and big-Oh
This week I leaned binary search tree and big-Oh. Also I finished is_regex and all_regexpermutations and build_regex of A2 in this week. However, regex_match was harder than the other cases, because I must consider special cases for StarTree and Leaf epsilon. StarTree and Leaf of Epsilon match empty string therefore I have to make more if statements.

I think the definition of binary tree is that each node of tree has 0 or 1 or 2 nodes, and the data in left subtree is less than the data in right subtree. This structure makes it easier to find a value in the tree and delete a value from the tree. For example, if data to delete is less than at node, it deletes from left and return it's node. If data to delete is mode than at node, it deletes from right and return it's node.

Searching a value in binary tree is more efficient than searching linear list. If I research linear list, we must investigate every element in the list. However, if I research binary tree, I am allowed o ignore half the list. If the data I want to get is less than the node, I can ignore the right subclass and search only left subtree.

Running time means time to run the code. We can find the running time of each code and find the best code to solve questions faster than the other codes. If an algorithm runs in number of steps no more than cg(n), we say the algorithm is O(g(n)). This means that running time of the algorithm faster than cg(n) as the size of input grows.


 

0 件のコメント:

コメントを投稿