On week 9, there was not much new stuff we learned because we had the second term test on Wednesday. On Monday, our professor wrote a function called delete. This function consists several if statements because it works for binary tree and comparison is required. I personally think this function is advanced. The reason is it took me a long time to just understand the code. In the first look, I was so confused because I couldn't figure out how this function deletes node. It seemed no variable was assigned by new data. But eventually it found the hidden code, it was below the "else" and new data was from a helper function. That helper function is recursive.
I hope I can learn how to write it shortly.
Sunday, 15 March 2015
Linked List
On week 8, linked list were introduced. It is a liner sequence of nodes. This means each node can only connect one node. We also learned two terms - front and back. Front represents the whole linked list and back represents the last node. It seemed to be easier than tree. However, when we started to build some functions like delete_back or append, there were several variables we need to change. For example, front, back, and size should be changed in the function delete_back.
To draw a picture before writing codes is helpful because sometimes people cannot visualize linked list in their heads very well. Instead, if we draw a picture, it would be clear that which variable is going to change and how it would change.
To draw a picture before writing codes is helpful because sometimes people cannot visualize linked list in their heads very well. Instead, if we draw a picture, it would be clear that which variable is going to change and how it would change.
Friday, 27 February 2015
Binary Tree
On week 7, professor Denny introduced binary tree. Each node in binary tree has two subtrees (left subtree and right subtree), or no subtree. Moreover, binary tree can represent a binary arithmetic expression because of its property. The definition of binary tree is that data in left subtree are always then than node's data. Similarly, data in the right is bigger than node's data. This gives us a relatively simple way to search. Sometimes we can avoid checking each subtree by comparing data. This saves us a lot of time.
I wrote some functions related to binary tree in this week's lab. All of them required recursion. It was not quite easy to write a recursion line because sometimes the idea was not very clear. It was even harder to express in form of code. To fully understand how to use recursion, I must practise a lot.
I wrote some functions related to binary tree in this week's lab. All of them required recursion. It was not quite easy to write a recursion line because sometimes the idea was not very clear. It was even harder to express in form of code. To fully understand how to use recursion, I must practise a lot.
Wednesday, 3 December 2014
Countable and Uncountable
On week 9, we learned how to determine whether a set is countable or uncountable. A set is countable if and only if it is listable. For example, rational numbers are countable because they can be listed. Also, the number of elements that a countable set has is no larger than the size of natural numbers. Interesting enough, the size of even natural numbers is equal to the size of natural numbers. However, the size of real numbers between 0 and 1 is beyond the size of natural number. No matter how you list them, I can find a number that does not appear on your list. This means that the real numbers between 0 and 1 are not listable, therefore they are uncountable.
Computable and Non-Computable
There was a fall break on week 11, so we had only 2 lectures on that week. We learned the difference between computable and non-computable. If f is a well-defined function and we cannot compute f(x), then f is non-computable. Otherwise it is computable. Also, we can use reduction to prove a function non-computable.
Big-Omega and Theta
On week 10, our professor introduced big-Omega and theta. We tried to solve more complicated examples. For instance, ∀f, g ∈ F, f ∈ O(g) => g ∈ Ω (f) is a typical implication about big-Oh and big-Omega. When the proof is getting longer, the structure becomes very important. The steps we write should be clear and every line needs to be explain in detail.
Proof and Disproof of Big-Oh Statements About Polynomials
On week 9, we learned how to prove and disprove big-oh statements about polynomials. To disprove an big-oh statement, the trick is that we need to negate the statement and find an n which consists with B and c. In some case, we have to use limit and L'Hopital's Rule in order to pick a correct n.
Subscribe to:
Posts (Atom)