Still working with recursion.......and recursions....... and recursions.......
But it looks like things are paying off. One of the biggest problems I had with recursion was that I would try
really really hard to think like the computer. Instead of thinking too much about the recursive steps that the computer takes, it is better to just understand how to properly write a recursive function.
I have yet to begin assignment 2 but do plan on working with a partner tomorrow. Hope the assignment is not as long as assignment one.
This blog will keep track of my Journey through Computer Science 148 and Beyond!!!
Total Pageviews
Monday, 28 October 2013
Friday, 25 October 2013
Recursion
Try to Google "recursion"!!! Trust me!... it is going to be fun!
Recursion has been my main weakness so far. I usually understand what the exercises are telling me to do, but I always seem to be getting the structure of the recursion wrong. A lot of the time I get the base-case right but not the recursion step. I will try to do more examples of recursions and hopefully everything works out in the end.
If anyone has any advice do let me know :)
Recursion has been my main weakness so far. I usually understand what the exercises are telling me to do, but I always seem to be getting the structure of the recursion wrong. A lot of the time I get the base-case right but not the recursion step. I will try to do more examples of recursions and hopefully everything works out in the end.
If anyone has any advice do let me know :)
Friday, 11 October 2013
Self-Reflection + The importance of Object-oriented programming and Recursion!
One thing that has struck me this past week has been the fact that group work is highly important in programming....more important than I thought previously. This thought came as the deadline for assignment one was looming and I was still stuck on tour.py. In a group, team members are much more likely to catch silly mistakes other team members make on their code.
The labs for example need to be completed by a group of two students. One student acts as the driver (writes the code) and the other student acts as the navigator (reading out the design recipe and making sure there aren't any mistakes being made). This relationship as first did not have much significance for me but after making so many silly mistakes and wasting time figuring out the silly mistakes I could have been much faster with completing my assignment if I had chosen to have a partner.
Now on to a completely different topic! Object-oriented programming is rather new for me. I started it briefly at the end of csc 108. Now that I have really gotten a taste of what Object-oriented programming is about I can give my thoughts about the topic. For simplicity sake I will abbreviate Object-oriented programming as "O-op".
O-op gives the programmer much more control over their code. Just relying on python's built-in functions can be rather troublesome as many of the built-in functions have attributes that perhaps you do not want in your code. In O-op you create an object and give it certain attributes. For example when creating a program you have a list that perhaps you do not want being altered in a certain way. A normal list would have the built-in function (append(), pop() etc). But in a O-op you could have a list which cannot have its items be removed. A regular python list can have items added to the front or the back. Perhaps you only want new items being added to your object from the front. In that case you would give your class a method which adds new items to front. If anyone uses your code and tries to append an item to the back, they would raise an exception or get an error. For this reason and many more O-op is a much appreciated method for programmers wanting more control over their code.
In addition to O-op another important wonderful thing has happened. I finally learned recursions. Recursions are loops where a function calls itself in its own function body. At first it was hard to understand how such a thing was possible. But after numerous examples it slowly becoming more and more understandable. Recursion first of all is important because of its simplicity. The code can be so simple yet to powerful. If you have a function which finds the maximum number from a list of numbers, it becomes a problem if there is a list of numbers inside the list of numbers. Obviously an error will occur in a simple code. But with recursion the program can literally call itself and find out the maximum number in the inner list and then compare it to the numbers in the outer list. Recursion is also needed when creating a tree. A tree looks really complicated when you are trying to create one without recursion, but with recursion the process feel a lot more easier.
The labs for example need to be completed by a group of two students. One student acts as the driver (writes the code) and the other student acts as the navigator (reading out the design recipe and making sure there aren't any mistakes being made). This relationship as first did not have much significance for me but after making so many silly mistakes and wasting time figuring out the silly mistakes I could have been much faster with completing my assignment if I had chosen to have a partner.
Now on to a completely different topic! Object-oriented programming is rather new for me. I started it briefly at the end of csc 108. Now that I have really gotten a taste of what Object-oriented programming is about I can give my thoughts about the topic. For simplicity sake I will abbreviate Object-oriented programming as "O-op".
O-op gives the programmer much more control over their code. Just relying on python's built-in functions can be rather troublesome as many of the built-in functions have attributes that perhaps you do not want in your code. In O-op you create an object and give it certain attributes. For example when creating a program you have a list that perhaps you do not want being altered in a certain way. A normal list would have the built-in function (append(), pop() etc). But in a O-op you could have a list which cannot have its items be removed. A regular python list can have items added to the front or the back. Perhaps you only want new items being added to your object from the front. In that case you would give your class a method which adds new items to front. If anyone uses your code and tries to append an item to the back, they would raise an exception or get an error. For this reason and many more O-op is a much appreciated method for programmers wanting more control over their code.
In addition to O-op another important wonderful thing has happened. I finally learned recursions. Recursions are loops where a function calls itself in its own function body. At first it was hard to understand how such a thing was possible. But after numerous examples it slowly becoming more and more understandable. Recursion first of all is important because of its simplicity. The code can be so simple yet to powerful. If you have a function which finds the maximum number from a list of numbers, it becomes a problem if there is a list of numbers inside the list of numbers. Obviously an error will occur in a simple code. But with recursion the program can literally call itself and find out the maximum number in the inner list and then compare it to the numbers in the outer list. Recursion is also needed when creating a tree. A tree looks really complicated when you are trying to create one without recursion, but with recursion the process feel a lot more easier.
Subscribe to:
Posts (Atom)