Recursion. It's a concept I've heard before in computer programming, where your implementation of a function calls the function itself one or more times in its body.
Recursion makes certain functions easier to implement, such as calculating the sum of nested lists or a factorial. It comes with two parts: the base case and the general case.
Tracing a recursive function seems pretty trivial to me, but designing a recursive function doesn't feel very easy. I always had trouble figuring out the general case, especially during the lecture exercises. Luckily, understanding recursion only comes with lots and lots of practice, and I plan to get a lot of that from looking at the example code or practice making recursion functions.
As for infinite recursion, I won't have trouble with that since figuring out the base case for recursive functions seems pretty easy to me, and base cases are termination conditions for recursive functions.
There was also a lab somewhere in the 6th week, but I don't think there was anything special there (other than learning about two built-in functions, zip and filter).
Saturday, February 27, 2016
Saturday, February 13, 2016
Midterm 1 and Assignment 1 (Week 5)
There was nothing new in the course curriculum so far, but I have managed to comprehend how linked lists actually work from an ADT perspective. Implementing the functions and reading the code for linked lists seems pretty hard at first, but I found out that drawing pictures and writing pseudo-code really helps.
I also learned in lab that experienced programmers do draw pictures of what code to write when they implement code similar to linked lists.
And speaking of linked lists, I have a feeling that most of the course is just going to be learning about more ADTs, with some algorithms and recursion, but mostly on other ADTs such as binary trees. I also have no idea how Assignment 2's going to apply all the content we've learned so far, but I did hear from my professor that I'd need a partner to complete it. But enough about Assignment 2, I've got Assignment 1 to complete. I have completed half of the starter code, but I'll have to run a lot of testing and debugging to make sure I take care of all the cases.
As for the midterm, it went pretty well. I was just worried about the extreme time constraint because 50 minutes, for me, is not enough time to even check your work or plan your answers. I realized then that using @param for the docstrings takes too long for such a limited amount of time, so I had to switch to @type in the middle of writing one of the questions. Luckily, most of pseudo-code and implementation was correct, so I think it's a minor error on my part.
For some people, the assignment gives them a lot of flexibility to write their own code, but I feel like there's not enough client code to even write the implementation for all the possible cases. Maybe that's what a real programmer feels like: you're only given the semantics and the rest of the implementation is up to you. I highly doubt that the professors will give us more client code, so I guess I'll just have to make due with the ones I have... by writing my own.
We'll see how well I can manage my duties on Assignment 1. It shouldn't be too hard, but I heard it's a lot to code.
I also learned in lab that experienced programmers do draw pictures of what code to write when they implement code similar to linked lists.
And speaking of linked lists, I have a feeling that most of the course is just going to be learning about more ADTs, with some algorithms and recursion, but mostly on other ADTs such as binary trees. I also have no idea how Assignment 2's going to apply all the content we've learned so far, but I did hear from my professor that I'd need a partner to complete it. But enough about Assignment 2, I've got Assignment 1 to complete. I have completed half of the starter code, but I'll have to run a lot of testing and debugging to make sure I take care of all the cases.
As for the midterm, it went pretty well. I was just worried about the extreme time constraint because 50 minutes, for me, is not enough time to even check your work or plan your answers. I realized then that using @param for the docstrings takes too long for such a limited amount of time, so I had to switch to @type in the middle of writing one of the questions. Luckily, most of pseudo-code and implementation was correct, so I think it's a minor error on my part.
For some people, the assignment gives them a lot of flexibility to write their own code, but I feel like there's not enough client code to even write the implementation for all the possible cases. Maybe that's what a real programmer feels like: you're only given the semantics and the rest of the implementation is up to you. I highly doubt that the professors will give us more client code, so I guess I'll just have to make due with the ones I have... by writing my own.
We'll see how well I can manage my duties on Assignment 1. It shouldn't be too hard, but I heard it's a lot to code.
Thursday, February 4, 2016
ADTs and Assignment 1 (Week 4)
After we got our feet wet in OOP, we then focused on ADTs, which were abstract data types. At first, I thought that they were built-in classes in Python, but they're actually classes that we can make with Python's built-in functions. The methods and behavior are the same for everyone, but we can choose how we can make our class in many ways.
I really like how flexible we can be with our implementation, but since I'm still quite rusty when it comes to Python syntax, I might not be able to come up with the best code or algorithm, probably code that just works. To fix that remedy, I'll have to brush up on my Python syntax, especially on immutable and mutable built-in types and their methods.
I did have a lot of trouble trying to follow the implementation of a linked list and why people tend to use linked lists rather than, say, huge lists. I'll see if I can find the answers from my professor's notes and Python code.
Other than that, I started my Assignment 1, which is just an application of what we've learned so far, creating classes and writing up implementations for built-in API. I'm curious to see where I could apply further concepts of CSC148 into the classes I'm implementing as I go along.
I've done two files so far, but I did have some trouble finding where the client code was in our starter code. Luckily, I got an answer when I asked on Piazza, but not what I was expecting: I learned now that client code was not only code that customers and clients would use my classes, but also programmers and other implementors that would want to use my code/classes in their code/classes. It's a really neat definition, but it just made my assignment a lot harder.
Now that I've thought about my assignment, is my list of classes there ADTs? Because I'm assuming that there's a same set of methods and behaviors for each of the classes (for everyone), but everyone can implement them in a different way. Inception.
Midterm's coming up next week, and oof. OOP and ADTs seem pretty intuitive; I might need some practice actually applying them to many different cases. Wish me luck.
I really like how flexible we can be with our implementation, but since I'm still quite rusty when it comes to Python syntax, I might not be able to come up with the best code or algorithm, probably code that just works. To fix that remedy, I'll have to brush up on my Python syntax, especially on immutable and mutable built-in types and their methods.
I did have a lot of trouble trying to follow the implementation of a linked list and why people tend to use linked lists rather than, say, huge lists. I'll see if I can find the answers from my professor's notes and Python code.
Other than that, I started my Assignment 1, which is just an application of what we've learned so far, creating classes and writing up implementations for built-in API. I'm curious to see where I could apply further concepts of CSC148 into the classes I'm implementing as I go along.
I've done two files so far, but I did have some trouble finding where the client code was in our starter code. Luckily, I got an answer when I asked on Piazza, but not what I was expecting: I learned now that client code was not only code that customers and clients would use my classes, but also programmers and other implementors that would want to use my code/classes in their code/classes. It's a really neat definition, but it just made my assignment a lot harder.
Now that I've thought about my assignment, is my list of classes there ADTs? Because I'm assuming that there's a same set of methods and behaviors for each of the classes (for everyone), but everyone can implement them in a different way. Inception.
Midterm's coming up next week, and oof. OOP and ADTs seem pretty intuitive; I might need some practice actually applying them to many different cases. Wish me luck.
Subscribe to:
Comments (Atom)