Hello ALL!!
This is my second last post and I would like to revisit my very first post, why geeks should write.
In my first post, I stated that the reason for programmers to write or keep a journal is for the purposes of communication, collaboration as well as reflection. Throughout this semester, I was able to demonstrate this idea by myself as I keep updating this slog. Now, I am more confident to say that writing surely is beneficial for programmers. I would like to reflect on my journey of keeping this slog and further explain why I think geeks should write, so please continue reading!!!
First of all, as a student who has been in Canada for only two years, language barrier is always a big challenger for me. Even though I may understand everything that was taught in class, sometimes I have trouble expressing myself. However, as I keep writing and summarizing course materials in this blog, I find myself more comfortable explaining ideas and concepts in English. As before, I may spend hours trying to put up one journal or slog, but now it would not take that long any more. The truth is, my writing skills as well as speaking skills improve by keeping up the habit of writing blogs every week. As a result, I would strongly argue again, as in my first post, that writing improve programmers' communication skills in all perspectives!
Next, writing is crucial for computer scientists as it encourage collaboration. In fact, I regularly visit other students' slogs and leave comments when I feel like to (too bad no one leave comments here :( ). It is beneficial to see how others think about the course so that I can be sure I am on the same page as well. What's more, some of the slogs are just so interesting that they give me a lot of inspiration. For example, this slog includes a lot of discussion beyond the material that was taught in class. Reading this blog, I was also encouraged to search for more applications about recursion and linked list on my own. I have to say that blog as well as piazza are really good way to help students connect with each other in this course. Again, collaboration is important in the field of computer science. As a programmer, you want to stay up-to-date and surely you can't achieve this by yourself. My experience of keeping this slog has really made me believe that writing or keeping blogs encourage collaboration between students. I am sure you feel the same way as well : )
Last but not the least, writing slogs every week give me an opportunity to reflect on what I have achieved and what mistakes I have made. If you go over all of my posts here, you will find that I regularly post comments on quizzes, labs, assignments as well as tests. These are all great study materials for exam as I can refer back to what I find the most difficult to understand. At the same time, I tend to summarize my understanding of course materials in my weekly slog. Surprisingly, I find that doing this not only help me understand the concept better, but also help me remember them as well. As we are out of help from our TAs for the second part of this course, I do find slogging every week keep me updated about what is new in the class and continuously reflect on my study habits as well as the challenges I face.
Visiting other sloggers, I do find someone has a similar feeling as me in terms of keeping a blog, like this one. As I wrote in my first post, "every programmer should keep a journal or blog that records his or hers progress in programming. A journal can help you keep track of what you have done, what mistakes you have made and what you have learned from it. In this way, you ensure you understand the course materials and keep reflecting on failures or debugging processes. " I think keeping this slog has definitely achieved this purpose, so that I would state it again that I agree with my earlier self, Geeks should WRITE!!!
Saturday, March 28, 2015
Saturday, March 21, 2015
Test Cases and Assertion
Hello sloggers!! This week we talked about unit tests and assertion. In class, we went over the implementation idea for minimax and I am glad that we had a similar approach. One problem I encountered when I was trying to test on Assignment2 is that, no matter how many times I try playing the game, I still feel uncertain about my algorithm. This week's lecture actually provided an answer to this problem, Danny explained how to choose the "right" test cases and the possibilities of getting them all right at the same time is extremely small. I am now confident about our minimax algorithm as it passes the test cases we discussed in class. One thing I forgot to mention in the previous post is how we had trouble dealing with lists as parameters passing between functions. This posed a dangerous and really serious problem, as any changes you make to one list affect all the others that have a same reference. We found the solution after hours of trying detect the problem and we used deepcopy to solve this problem. In lecture, Danny introduced another way to make a copy of list instead of using deepcopy, and it looks like this
The syntax is
assert «condition», «error_string»
So the meaning for this statement is, if condition fails,
raise AssertionError(error_string)
I think these will definitely become handy as I am doing my last assignment. I have learned how to perform effective test cases and I will apply the knowledge to A3.
L3 = [[item for item in r] for r in L1]
I find this really interesting, since if you just put one forloop for the inside list, you end up only protecting the elements in the inside list from changing. To protect the whole list, you have to do it like that.Another new thing we learned is assertion. It is a tool that can be used to state what we know is true at a crucial point in the code or what we assumed is true at the start of a function or method.
The syntax is
assert «condition», «error_string»
So the meaning for this statement is, if condition fails,
raise AssertionError(error_string)
I think these will definitely become handy as I am doing my last assignment. I have learned how to perform effective test cases and I will apply the knowledge to A3.
Saturday, March 14, 2015
Reflection about A2 & Test2
Hi sloggers!! Can't believe we already past 2/3 of this course ... and congratulation on finishing assignment 2 and test 2!! This week we had a test, so we did not learn much. I will just do a quick summary and talk about how I think of A2 and Test 2.
In class, we went back to BST and talk about how we can add and delete an element. It may seems like a simple task, but in order to make sure the datas are organized in the way we want, we got to do some extra work. Here is the algorithm for deleting a node.
you have to consider all the possible cases and I personally find number 5 hard to understand. Yet, if you think about this: you have a node that has two children and you want to delete it. Your replacement of that node should still make the tree a proper BST, which means all its left nodes must be less that the replacement node. Therefore, you have to either replace it with the largest from the left or the smallest from the right. It looks complicated, but it actually make sense if you think about the problem in a logical way.
Assignment 2 is definitely harder than the first one. The process of tackling recursion is like you feel like you get the answer, but after a while it does not make sense to you any more. However, once you get it, then you actually get it. I am so glad that Danny was willing to stay for almost 1.5 hour after Wednesday's class at night. I also really enjoy discussing the problem with my teammates, even though rough_outcome surprisingly gave us a hard time after we finished minimax, we were able to finish it at time. I hope the strike can end soon so we can get our results back!
Test 2 is fair in generally, I am glad that I reviewed the lab problems on my own and put them on the cheat sheet (they're really handy>>>)
That is all I want to say. Hope you all have a great week!!!
Sunday, March 8, 2015
Link Them Together - Impression of Linked Lists
Hi sloggers, it is a new week again. Something unfortunate happened this week and I am sure you all must know about this, the strike. Sadly, I lost all of my tutorials but also got 4 hours of extra spare time every week. I hope that school can settle this properly as soon as possible. Tutorials are always beneficial as they offer practices for what I learned in class and my TAs are all really nice and good at explaining concepts. Anyways, I will try to keep up with my studies so let's talk about the new data structure we learned, Linked List!
A linked list is a sequence of nodes, each of which contains a value and a reference to the next node.
We used LLNode to represent a single node and LinkedList to represent linked list, which we call the wrapper class. Well, questions has been raised about why do we need this wrapper class. The answer is we want to know where does the list start and where does it end. otherwise, the data structure would not make any sense.
Here is how you can think of a linked list in visual. Each box represents a LLNode
The __init__method of a LLNode class
Notice that self.nxt is None iff we are at the end of list.
we keep a reference to the front/head of the sequence. The back of the sequence is called the tail.
traversing a linked list poses a little bit trouble as we can't access each node directly as in a normal list. Thus, we need to "walk through" a linked list and the general pattern is like this.
We want to be able to perform normal operations like adding and deleting on a linked list. However, you gotta be extremely careful cause sometimes we may go so far in our "walk" that we lost the reference to go back one more step to make the changes we want. The solution is to walk 2 references along the list, with one trailing behind a step.
There are a lot of practices in this week's lab, but I found them challenging as I went through them to prepare for next week's test. So, I discussed them with my friends and compared answer with the one Danny posted on course website. Here, I want to include one example and discuss some of the key points that I think deserve attention.
The key to any linked list problem is to DRAW PICTURES!! They are extremely handy in terms of understanding the whole process.
To start, suppose we have a linked list like this
Say we want to insert a node before A. We need to first walk through the list to find node A, then change the reference of E to refer to the new node and link the new node to node A. Clearly, we need 2 references as we are walking through the list, since we want to access E after we find A.
The picture looks like this. This is the general case and let's first write code up to the point we find node A.
This looks straight forward, but before we proceed, we still need to consider some special cases. 1. what if v2 is not in the list? then after the search for v2, cur_node would be None. 2. what if v2 is the first in the list? then we technically did not go into the while loop, so prev_node is None. keep this in mind and we can generate the rest of the code.
This is not that bad right? Again the key is to draw the pictures. I still need to practice more since I sometimes overlook the special cases, which can cause a big problem. I actually want to do a comparison between list and linkedlist, since they simply perform the same sort of tasks. Yet, today we have enough to say so I may go back to this post to continue on this topic or I may just simply do it in a later post. Thanks for reading and good luck on test2!!!
Subscribe to:
Posts (Atom)









