Recursion is one of the most useful tools in programming as it allows program to run more efficiently and effectively by calling the function itself over and over again. An example of recursion can be found in the first assignment in this course.
In the 5th step of the first assignment of the course, I am required to implement the move method from TOAHModel class over and over again. The first step is to move n - i many cheeses from the original stool to one of the intermediate stool. This can be done by creating a recursive function that instruct cheeses from the original stool to be moved to one of the intermediate stools for n - i many times. Then, I used recursion function to move i cheeses from the original stool to the destination stool, again, by using recursion. Lastly, I moved n - i cheeses that are stored in one of the intermediate stool into the destination stool. Because of recursion, this implementation can be expressed in only about 15 lines excluding the headers, doctrings, and comments. However, without the help of recursion, it might take longer lines to execute this implementation.
I find the concept of recursion to be very simple to grasp. I can easily understand what I am required to do and how recursion is needed to get the functions to run. However, I often struggle when I have to write the recursion body. It is difficult because it requires me to think creatively and cleverly to find the corrent code in order for the functions to run. I am still wondering how I can improve my creative thinking skills so that I can quickly write the correct code in recursive functions. At this time, the best solution that I can think of to improve my problem solving skills is to face a lot of recursion problems and try to find the correct code.
Recursion function is useful expecially when programmers face problems that require them to execute the same function over and over again but using different arguments. For example, the nested_depth function from the lecture requires us to repeat the body of the function if the item in the list is a list, and it will require us to use recursion until the item in that list is not a list. Programmers use recursion to instruct the function to do the same thing with different arguments until it meets the expectation of the question. This is why recursion is useful because otherwise, programmers have to keep duplicating the body of the function, which is not very effective and efficient.
Friday, 28 February 2014
Thursday, 6 February 2014
This week I learnt more about recursion. I didn't find recursion to be difficult. I really enjoy learning about this tool and I believe that recursion will be helpful in writing more effective and efficient code. In addition, I am starting to work on my assignment 1 this week. The assignment seems to be quite challenging because it requires me to think outside the box to figure out how to write a correct program that is effective and efficient code. I think I will use recursion in this assignment and I am looking forward to finish my first assignment in this course soon.
Monday, 3 February 2014
Last week, I learnt about recursion and I enjoy last week's lectures. I find recursion to be an amazing tool in programming because I think recursions help programmers to write more effective and efficient programs. The part of the lecture that I enjoy the most is when the instructor (Danny Heap) showed the class how to draw in Python by importing class Turtle and it uses recursion to make the drawings. What I am looking forward after learning about recursions is to write programs that use recursions, such as writing a program to calculate the area under the curve of a particular function (integration) and some mathematical inductions.
Thursday, 23 January 2014
I found it difficult to learn computer programming because I do not have the background in programming. I took programming courses in grade 10 and grade 11, but I do not feel that those courses prepare me for computer programming courses in university. I passed CSC108H1 and my mark was decent (it's slightly above the average), but I feel that my programming skill is still very little compared to my peers.
For the first three weeks in class, I learnt about how to write classes.The first time I learnt about writing classes is when I took CSC108H1 and it was only discussed for 1/2 weeks. This is why I found it difficult to keep up with the course. It seems that I have to spend so much time (2 days or even more in a week) to read the readings and understand the materials well.
I think the key to get better and better in learning object-oriented programming languages is to practice and write code regularly. Learning object-oriented programming languages is like learning piano: if you practice a lot, then you will get better and better, but if you don't then you won't get good at it. I am trying to keep practicing whenever I have the time to do so, though this is difficult to do since I also have other courses with pretty high course workload.
One last thing that I think is extremely important when learning about something difficult is to have the desire to learn the material and to never give up even though I keep receiving marks that I am not satisfied with.I believe that the desire to keep learning and trying is the key to become a successful person and that is why I won't give up learning computer programming.
Subscribe to:
Posts (Atom)