At very beginning of this semester, I talked to one of my friends who already took csc148 in 2014. When I asked her that how did she thinking of csc148, is it difficult? She said the recursion is very hard. Of course, I had no idea what recursion really stands for except that I think it a very cool name. Not until the last week, we finally been introduced to recursion. The starting introduction is very friendly because the example is dealing with the simple question--addition of numbers. we are given a problem at first, to sum a given list. The build-in function could easily solve it for us if the nest contains only integers. However, if the given list contains more than just integers, but a nested list, the build-in function 'sum' doesn't work for us anymore. I remember back to csc108, I used to encounter a similar problem that I need to sum a list where the list itself contains lists. for example, S = [ [5,6], [3,4], [1,2] ]. I remember what I did was to create a new list.
Apparently, this is very inefficient way of doing it, first it requires that each vector in the list much have same length 2, second it doesn't solve the case if the given list contains integers mixed with list, or list of list of list etc. Also, thinking about the running time, it's not the good way of solving such problems if we take the consideration of any of above we mentioned.
I don't who comes up with the idea -recursion, but when I first time saw it, I was very impressed that defining a new method in term of the method itself, functions can call themselves to solve smaller sub-problems.
So far, we haven't taught how to write a proper recursive function. All we do is trace each step. This part requires attentiveness and calmness so that we don't get upset and messed up when the given input is too complex.
Sunday, February 8, 2015
Sunday, February 1, 2015
Week 4
This is a very busy week. Particularly due to the first assignment. From assignment, more than just learning the difference between __str__ and __repr__, how to use subclass After the first assignment, I start to realize how easy CSC108 was last year because 148 is completely a new level of programming. In CSC108, when we write program, we were almost given anything that we need. We were given the program outlines, starting codes, what kind of function we need, doc-string, examples, and instructors even completed all the programs codes. Basically, in CSC108, we don' need to think how to start a task, or where to start. We don't need to think what is needed for this program to be successful, or learning how to carefully plan step by step to solve the problems. All we need to do in 108 is just finish the uncompleted codes for most time, I myself without even thinking why is it needed or what is it related to the other functions or overall program. In 148, everything changes. For the first assignment, we are only given a instruction of program, without any starting codes, plan, examples, functions provided. I felt overwhelmed at first after been spoiled so much in 108. I spent much more time on thinking overall and planning than the time I spent on actually writing the codes. I can't remember how many times I've completely delete what I've done and re-start just because something I didn't think carefully at beginning. In CSC108, I barely read assignment instruction, I just download the starting codes and mechanically completed the codes, In 148, it involves more creativity, and our own way of planning and thinking. More challenging thing is that, this assignment is merely a starting for the next two assignments, which means that we have to make sure that when we continue next time, the additional class or codes must comfort with the one we are writing right now, we need to make the code to be as flexible as possible and meanwhile, it must be easy amend in future time. We need to build a structure that we might use in the next two assignment. Some nights, I even thinking about the assignment even when I'm sleeping. Of course, when I finish the program finally, it yields more satisfaction and I'm very looking forward to the next assignment as well.
Subscribe to:
Posts (Atom)
