First, I'm so glad that the strike was over. Also, the semester is coming to an end. Throughout the semester, the content of CSC148 is more class-based, whereas CSC108 teaches far more about how to write out codes and debug. Therefore, I would say CSC148 is more conceptual.
Look back all my posts, I wrote about Object-Oriented-Programmings most. Since python's world is all about objects and classes, such as Trees, Linked-lists, BST and so on. When I was learning CSC108, classes were confusing me. During the course of learning CSC148, I have found myself getting my way into OOP. Now I even have started to like it.
This is a interesting course for me. At the beginning I decided to minor in computer science but after this course, I have changed my mind. Now I'm pursing a double major in computer science and statistics. Due to this course, I've started to love doing labs, which I hated most in high school. Coming labs every week helps me think about and practice the materials learned in lectures weekly, since during lectures I can hardly think independently. However, during labs with TA's help, discussions and multiple corrections, I was able to absorb materials.
Thanks to Danny, Diane, and my lovely TA. I had a wonderful experience and feel ready to study higher level computer science courses in the following years. :)
CSC148
2015年4月2日星期四
2015年3月27日星期五
Week11: Revisit OOP
Thanks for the blog I commented :http://computersciencemaggie.blogspot.ca/2015/03/summary-of-object-oriented-programming.html?showComment=1428022607229
In my earlier post, I only discussed about the concepts of class and inheritance. In ComputerScience0909's blog, the author not only summarized in a more efficient and clear style, also discussed other Object-Oriented Programming concepts, such as Recursion, Trees, and AbstractDataTypes. Comparing to his ideas, I have found my explanations are not specific enough.
To sum up my thoughts so far, python's coding style is to class things up. Since my partner works part-time in the mobile gaming area, he has found out that they implement games by a 'Model, View, Controller' approach, which is similar to our Game_State class and Strategy class. I'm very lucky to have a partner who is enthusiastic in computer science. I have learnt a lot form him. :)
Also, this week we revisited sorting selections to study the efficiency of sorting. To understand the how these selections work clearly, the illustrations are needed for me. The following blogs summaries the selections clearly with good images.
http://darkfoxnewslog.blogspot.ca/2015/03/slog-for-week-11.html?m=1
Bubble sort

I'm feeling myself thinking more like a computer scientist!
In my earlier post, I only discussed about the concepts of class and inheritance. In ComputerScience0909's blog, the author not only summarized in a more efficient and clear style, also discussed other Object-Oriented Programming concepts, such as Recursion, Trees, and AbstractDataTypes. Comparing to his ideas, I have found my explanations are not specific enough.
To sum up my thoughts so far, python's coding style is to class things up. Since my partner works part-time in the mobile gaming area, he has found out that they implement games by a 'Model, View, Controller' approach, which is similar to our Game_State class and Strategy class. I'm very lucky to have a partner who is enthusiastic in computer science. I have learnt a lot form him. :)
Also, this week we revisited sorting selections to study the efficiency of sorting. To understand the how these selections work clearly, the illustrations are needed for me. The following blogs summaries the selections clearly with good images.
http://darkfoxnewslog.blogspot.ca/2015/03/slog-for-week-11.html?m=1
Bubble sort

I'm feeling myself thinking more like a computer scientist!
2015年3月21日星期六
Week10: Assertion and Unit Tests
This week we explored assertions, unit tests, and tracing function calls.
When you do
I found a website that provides some examples:
https://wiki.python.org/moin/UsingAssertionsEffectively

When you do
assert a_condition
you're telling the program to test that condition and trigger an error if the condition is false.
Syntax: assert « condition » , « error_string »
Meaning: If the condition fails,
raise AssertionError( « error_string »)
I don't really understand why we should use assertions. Although the handout said that assertions can help us avoid 'nosiy' output and save the time of testing, I didn't really see any examples to prove the efficiency of using assertions.Since the strike is on, I have no one to ask.I found a website that provides some examples:
https://wiki.python.org/moin/UsingAssertionsEffectively

2015年3月13日星期五
Week 9: modify BST instance
Due to the test, we only had one class this week. In the lecture, we explored BST methods which may modify the BST instance they are called on. Furthermore, mutations and iterations are not only related to BST, but to LinkList as well.
There is a general format for iterations in a LinkedList which I copied from the slide:
cur_node = self.front
while
After all, the test was easier than i thought and cheating sheet was really helpful for the last question. I only changed couple lines of __delete__ method.
def delete_after(lnk, value):
''' (LinkedList, object) -> NoneType
Delete node with value after the first occurrence of a
node containing value, if possible.
>>> lnk = LinkedList()
>>> lnk.append(3)
>>> lnk.append(5)
>>> lnk.append(7)
>>> lnk.append(9)
>>> delete_after(lnk, 3)
>>> print(lnk)
3 -> 7 -> 9 ->|
>>> delete_after(lnk, 7)
>>> print(lnk)
3 -> 7 ->|
>>> delete_after(lnk, 15)
>>> print(lnk)
3 -> 7 ->|
'''
if lnk.front:
cur_node = lnk.front
# walk along the list
while cur_node and not cur_node.value == value:
cur_node = cur_node.nxt #walk along the list
if cur_node and cur_node.nxt:
if lnk.back is cur_node.nxt:#if the node needed to be deleted is back
lnk.back = cur_node#just change the value of back to cur_node
cur_node.nxt = cur_node.nxt.nxt#if not the last node, delete cur_node.nxt
lnk.size -= 1#always remember to change the size of a modified link
However, I forgot to draw a diagram for the last question....sadly:(
2015年3月6日星期五
Week 8:Linked node and Linked list
After attending two lectures, still, I
didn't understand what a linked list really is. My way to understand a OOP
concept is to generate a diagram in my head when implementing functions or
initializing the object. Unfortunately, no pictures ever appeared when I saw
Danny's codes for LLNode and LinkedList until I read the reading Danny posted: http://openbookproject.net/thinkcs/python/english3e/linked_lists.html
Generally, a LinkedList(formed by LLNodes) has three variables: front(represents the first node), back(refers to the last node), and size(stands for the number of the nodes in the LinkedList).
Now while implementing methods I can understand what each line for.
Now while implementing methods I can understand what each line for.
For example:
def insert_before(lnk, v1, v2):
''' (LinkedList, object) -> NoneType
Insert a new node with value v1 before the first occurrence
of a node with value v2. Do nothing if no node has value
v2.
>>> lnk = LinkedList()
>>> lnk.prepend(5)
>>> insert_before(lnk, 4, 5)
>>> print(lnk.front)
4 -> 5 ->|
>>> insert_before(lnk, 3, 5)
>>> print(lnk.front)
4 -> 3 -> 5 ->|
>>> insert_before(lnk, 3, 7)
>>> print(lnk)
4 -> 3 -> 5 ->|
'''
if lnk.size > 0:
prev_node = None #always before cur_node
cur_node = lnk.front
while cur_node and not cur_node.value == v2: #if not None not v2, keep walking along the list
prev_node = cur_node
cur_node = cur_node.nxt
if cur_node and cur_node.value == v2: #if cur_node is v2
cur_node = LLNode(v1, cur_node)
if prev_node is None: #if the cur_node is the first
lnk.front = cur_node
else:
prev_node.nxt = cur_node
lnk.size += 1#always remember to change the size of a modified link
This week I prepared for the second term
test by reviewing labs and doing couple danny's past exams. Good luck!
2015年3月1日星期日
Week7: OOP and Tree Class
Please grade my previous post as my chosen topic is OOP:
http://ruolancsc148.blogspot.ca/2015/02/week-6-object-oriented-programming.html
http://ruolancsc148.blogspot.ca/2015/02/week-6-object-oriented-programming.html
Week 7 – continued
This week we continued on the topic of
object oriented programming – Tree Class. We continued implementing recursive
functions, but unlike the previous week, the input was a BTNode , the root of a
binary tree.
After initializing a BTNode, we constructed
different functions by using the concept of recursion. During the lab I've
found drawing diagrams is super helpful for clearing thoughts. I couldn't
figure out many functions until drew a diagram. For example, the last function list_longest_path:
def list_longest_path(t: BTNode):
''' List the data in a longest path of t.'''
L
= []
if not t:
pass
else:
L = [t.data] #collect the value of the root of the tree
if len(list_longest_path(t.left)) >= len(list_longest_path(t.right)):#collect
only left path if it is longer
L += list_longest_path(t.left)
if len(list_longest_path(t.left)) < len(list_longest_path(t.right)): #collect
right path if it is longer
L += list_longest_path(t.right)
Based on my understanding I kind-of
summarized a recursive algorithm for collecting data:
1. Create an empty list or dictionary;
2. Separate the base case (which is usually
very simple) and other cases that need recursive concept;
3. Set the requirements for data to be
collected.
All we need are a base case and a way of
proving that for any list, we will eventually get to the base case.
Also, I would like to thank Julian's
post(on which I commented):
It helped me to clarify and summarize every
concept Diane mentioned this week.
2015年2月13日星期五
Week 6: Object-Oriented Programming
Based on my understanding, Object-Oriented Programming(OOP) is a programming language model organized around objects. It's all about manipulating objects.
Here's a helpful video I found:
In this video, the teller introduces OOP concepts by explaining some terms first, such as 'module', 'class' and 'object'.
He prefers to think a module as a collection of classes and a class as a collection of objects.
To help understand these abstract terms, he defines a 'class' as a blueprint of what you want to create, for example, a buleprint of two-room house. Based on this blueprint, we can bulid houses- concrete froms, instantiation of the class- called as 'object'. To construct other parts of the city, we need houses in different structures(two-room, three-room and so on). A 'module' is a collection of the blueprints of houses in different structures.
Since these blueprints are similiar, to make it easier to create new houses, we can copy a part of attributes from the original blueprint, say a two-room blueprint. With the property of inhertance, two-room buleprint can be extended to three-room blueprint by adding one more room. In this example, the two-room bluprint is called 'base class' and the three-room blueprint is called 'derived class'.
订阅:
博文 (Atom)






