This week Binary Search Tree is introduced to us. Compare to a Tree, BST is easier to use and understand. It compares each nodes with the root and put the smaller ones on the left tree and the larger ones on the right tree. Then it keep compares everything and do the same. It decreases the working time compare to Tree.
Also, When I'm trying to do implement on BST, it's a lot easier than a Tree. I need to compare the value I'm gonna work with with the root of the BST, after that, I only need to deal with one side of the tree depends on the value is larger or smaller than the value of the root. This way it is a lot faster.
Wednesday, April 8, 2015
Week8 Slog
This week we have learned linked list. This is a linear sequence of nodes. It has two variables which is a front or head, and a back or a tail. Usually, the back of one front is also a front of the other back. This way, nodes are linked together to form a linked list.
The hardest part of linked list for me is to understand how it works. It is called a "list" but it's nothing like a list other than it's shape. It is formed by several nodes. So for sure you can't get any specific nodes but calling the index. It took me a long time to figure how to call a node by recursion. So it is fine for me now.
The hardest part of linked list for me is to understand how it works. It is called a "list" but it's nothing like a list other than it's shape. It is formed by several nodes. So for sure you can't get any specific nodes but calling the index. It took me a long time to figure how to call a node by recursion. So it is fine for me now.
Week6 Slog
This week we have learned about tree. This is a type of python codes. It has a root as the start and several leaf nodes assigned below the root. The most confusing part for me is that the nodes are not int or float or strings along. If I want to use the nodes, I have to say node.value to use it to either compare to print. Otherwise, it will print out an error. Otherwise, Tree is not hard to understand for me.
Week7 - Recursion
Recursion is similar to a circle. Usually, programmers write the complete functions before using it, but in Recursion, functions can be used inside themselves before they are completed.
Recursion is a way of programming or coding a function, in which a function calls itself one or more times in its body. It appears to me difficult to understand at the beginning. Thinking recursively is very important to this part. First of all, you need to make sure you have a start case which tells python what to do recursively. The start case is really important because it decides how the entire function works.
The start case usually claim the condition of where the variable is None or 0. Then it claims what will happen if the variable is not None. One example can be:
def node_count(root):
if not root:
return 0
else:
return 1 + sum([node_count(child) for child in root.children])
where it shows if root is None, the function returns the value "0" so every time when it runs to get to the end of the tree, it doesn't add another value to the answer.
Recursion is one of the best way to write functions so far. By writing codes recursively, it reduces a lot of work. It's also the fastest way to write.
Recursion is a way of programming or coding a function, in which a function calls itself one or more times in its body. It appears to me difficult to understand at the beginning. Thinking recursively is very important to this part. First of all, you need to make sure you have a start case which tells python what to do recursively. The start case is really important because it decides how the entire function works.
The start case usually claim the condition of where the variable is None or 0. Then it claims what will happen if the variable is not None. One example can be:
def node_count(root):
if not root:
return 0
else:
return 1 + sum([node_count(child) for child in root.children])
where it shows if root is None, the function returns the value "0" so every time when it runs to get to the end of the tree, it doesn't add another value to the answer.
Recursion is one of the best way to write functions so far. By writing codes recursively, it reduces a lot of work. It's also the fastest way to write.
Thursday, February 5, 2015
Week5 Slog
This is the slog for week 5. This week, we've learnt how to write test cases. This is kinda easy to understand. Up to this point, I'm familiar with most of the parts we have learnt so far but just a little bit confused about recursion. During this week, I've read over some recursion codes and have doen some pratices. After all those practises, I get the point of recursion which is giving python an example then ask it to do it itself over and over again until i want it to end. I think I can do better in the future.
Wednesday, January 28, 2015
Week4 Slog
This week, we had an introduction about recursion, which is the most confusing part for me in this course. In CSC108, and in CSC148 so far, we learned how to write programs and methods to work things out, but we can only use them when they are completely finished. However in recursion, it's completely opposite. We use the methods inside themselves as a part of the components before we finish writing them to make the methods repeatly doing the same thing. It is really comfusing for me that, how can a method work without being finished and how python read the code when the method is inside itself. But I think I will know how to do it perfectly at the end of this sememster by practising a lot and read many methods with recursion. This way, I will get very familiar with recursion and I will 'think recursively'.
Wednesday, January 21, 2015
Why geeks should write
Since I've learned a little bit of CSC148, I've got an idea how awesome and wonderful computer science is. When you success in writing a program or finally figure out how a function works, you will be fulled of satisfaction. And that's why geeks should write. They are smart, really really smart, so they are capable to write down as many programs as they want. As we all know, computer programs work faster and more accurate than human's brain. So as there are more useful programs been developed, our lives could get much more convience. So the geeks should write.
Also, the reason why they are called geeks, is because they always think differently from other people. So they are more easily to come up with some extraordinary ideas those could be really helpful for the development for our technologies. They should record the ideas so we don't lose a chance to step forward into a age of higher level of technologies.
That is why I think geeks should write. As a student of Computer Science, I wish there are more and better invention to be developed in the future so we can use them more easily.
Also, the reason why they are called geeks, is because they always think differently from other people. So they are more easily to come up with some extraordinary ideas those could be really helpful for the development for our technologies. They should record the ideas so we don't lose a chance to step forward into a age of higher level of technologies.
That is why I think geeks should write. As a student of Computer Science, I wish there are more and better invention to be developed in the future so we can use them more easily.
Subscribe to:
Posts (Atom)