We have introduced class Linked list in the last two weeks. For me it is more abstract idea than class Tree. I am still confused about what kind of problem should be and can be solved by using Linked List. So far my understanding of Linked List is a chain structure, but each part of the chain is also a chain structure. I also want to add something about recursion. The last assignment asks us to write minimax strategy. And from that I heard a very typical problem of recursion, Eight Queen. It looks really really confusing but I want to try to solve it before end of the term.
The class Tree we have learned this week is such a good tool for me to learn recursion, even though I haven't completely understood how and why my codes work or not. Tree has lots of "random" component, so in that case my recursion better to cover all the possible cases. For example, in this week's lab we were asked to write function that return the longest path of a binary tree. This is kind of simple since for each node there are maximum two paths. But how can I find the longest path of a random tree, one possible way I can image is using same approach as binary tree but add a for loop so for each path of a given node return the path. However, I still have some problem with built that code at the moment.
Object oriented programming is the programming model that we build our program on "object", instead of being collection of "actions". The example we have used in lecture is class Point, which contains integers as coordinator and contains methods so we can see how points interact. In this case, point is the object, and all the methods (actions) we have created are using that object to solve problems. Therefore, using object oriented programming model we first need to define what is the function of that "object". For example, Point, or GameState we have created in assignment 1. Second we need to know what property that object should have and how to store it. Third for the purpose of programming we need to build some method so we can actually use the object to solve problem. For example, the distance method from class Point. After we create the class we can start to think about what sub class are needed. In some case our object may be too generous and cannot be used directly for problem solving. For example, specific game state for subtract square. Here we can see the advantage of object oriented programming. We don't need to re-write every thing we have for super class. sub class can inherit method and property from their super class. We only need to write code for class-specific method.
I have mentioned recursion in last post a little bit. We have learned tracing function call in 108 and recursion in my opinion is the advance of that. I haven't completely understand how that works at this moment, even though I can get the correct answer for exercise. My problem is which step goes first and whats the exact change for every line in the function. And for writing a recursion, most of times I just tried some possible but not correct input, and finally, lucky i got the answer but I can't remember how I get there, I should not only tracing recursion next time, but my work as well
148 is an interesting course to be honest. Comparing with 108 we are no longer focusing on code itself. Instead, we are focusing on how to use those code to solve real world problem. I feel like this course requires lots of thinking. Image the whole picture of the program we are asked to write before we start to type the code. What we have as input, what we want to produce, etc. Of course we still leaning new method like recursion, which really confuse me a lot even when I write my quiz. I have spend whole night after quiz to figure out the correct answer of it, at the moment I think I understand the process of it and hopefully I can produce the right answer next time.
I am always thinking programming language and math expression are the same things, they both are nature language. Code or math notation itself can be understood worldwide no matter where he or she live and the language he or she spoke. But notation is just the tool for us to spread our thought and idea behind the notation and this part requires communication, specifically writing. As one of the blog posted on course webpage, a good writing skill helps geeks to persuade the receivers or other geek that the method they are using is better. And this hopefully can inspire them to use the idea somewhere else or even improve it. In particular, good inline comment makes our collaboration more efficient by helping colleagues understand the code properly.