We learned about recursion last week which was really confusing at the beginning when I saw the codes with it. Basically it's working like a for or a while loop but unlike a ''for'' or a ''while'', it divides the object into the smallest unit and implement a built-in function on it. Our professor said that it might be confusing when we saw it but after tracing the recursion we would find it magical and that was exactly how I felt after that lecture.
we were given an example where the method takes a list or a single number as the parameter and the code below called the method itself again(a recursion) because we didn't know the exact form of the parameter, which could be a nested list with any depth or just a number. It was hard to set the criteria for the loops in that case so recursion was useful. we started with the basic case where the parameter was a number and that gave us the value returned under the first 'if' requirement. As we proceeded I noticed that a nested list with any depth would eventually be dissected into the basic case where the object is a number and then we got the result using recursion even if the details of the parameter was unknown.
In conclusion, tracing recursions is a great way for us to understand how python works with recursions and that was definitely a clear and enlightening lecture.
Tuesday, February 10, 2015
Monday, February 2, 2015
week1-week4
Last week we submitted our first assignment in this course, which is a huge relief for me. To be honest the first assignment really scared me because we were given so much space in designing and implementing the codes as compared to last semester. In CSC108 the instructors would tell us exactly what to do in an assignment and walk through almost every steps with us and there were a lot of restrictions on the codes. In CSC148 we suddenly become the 'real' computer programmer because most of the content on the assignment handout is about the idea and the structure of the program instead of the details of the codes and the restrictions. It involved a lot more thinking and we had to apply everything we know in computer science which is a good thing and a bad thing because it could be discouraging sometimes. I still don' t know if it was too early for us to do this.
Except for the big assignment, we did classes and subclasses for the first few weeks. At the end of CSC108 we had the topic of designing a new class in Python but I would say it was memorizing rather than designing because it was too abstract for me and I had no idea why we had to create a new class. I have a better understanding of classes now after learning how to actually design a class as needed and add specific methods for it. Subclasses were confusing at first as well and my biggest question was why designing several subclasses for a useless superclass while every subclass could be an independent class? Later it was solved as I saw more examples and got a better understanding of inheritance.
(Praying for the upcoming test)
Except for the big assignment, we did classes and subclasses for the first few weeks. At the end of CSC108 we had the topic of designing a new class in Python but I would say it was memorizing rather than designing because it was too abstract for me and I had no idea why we had to create a new class. I have a better understanding of classes now after learning how to actually design a class as needed and add specific methods for it. Subclasses were confusing at first as well and my biggest question was why designing several subclasses for a useless superclass while every subclass could be an independent class? Later it was solved as I saw more examples and got a better understanding of inheritance.
(Praying for the upcoming test)
Subscribe to:
Posts (Atom)