While the material covered this week in lecture wasn't entirely new, the way in which it was described and dealt with was. I had come across it during a lab several weeks ago, in which we dealt lists within lists with a series of numbers and "None" placed within them; I am of course referring to "trees". It was difficult to deal with then, and so I was fortunate that my lab partner that week had a better grasp on the idea than I did. The lecture this week did shed some light on the subject though, and so I am finding it a little easier to grasp. However, despite the added help, I am still finding the whole thing a little tough to tackle, especially as far as writing the code goes.
As far as the concept goes though, I am understanding what trees are. The diagrams provided in the slides and during the lecture helped me understand how they work, as did the definitions and key words associated with binary "trees". And, through this I have managed to learn a little more about recursion, and how the various parts call upon one another. I of course knew beforehand what recursion was, and how to write the code for it, but the visual help aided in cementing the idea in my mind as to what recursion really is.
Sunday, 16 February 2014
Sunday, 9 February 2014
Recursion
I must say that, upon first being introduced to recursion, I was not entirely sure as to what its significance was. Using "for loops" and "while loops" had always worked for me, and so I had seen no need for anything else. It was also somewhat difficult at first for me to grasp recursion, despite its simplicity, and so that proved to be another deterrent. However, upon further inspection of examples, and my own experiences with attempts to use it, I found that it became quite handy. Its use of short and usually simple code made it desirable for use instead of a "for loop" or a "while loop", which would sometimes become quite long and redundant. I also found that it proves to be much more versatile in its uses, as it has the potential to perform iterations many more times with fewer steps than any of the loops, while also being capable of doing more than a loop with an equivalent or even longer length of code.
This week's biggest problem, though, came from the lab work. My partner and I were having extreme difficulties with the finalization of our first recursion code, and we could not tell at all where the problem was originating from. Therefore, we decided to move on to the freeze code, which we finished relatively quickly, in order to clear our minds of the first code. We ended up staying at the lab a good half hour more than we were meant to in order to finish the code and determine the source of the problem. We were literally at our wits end, until finally, almost as a joke, we decided to add "return" to the end of our code, thinking that it couldn't possibly be the source of our misery. Lo and behold though, our code worked perfectly after this, and we laughed at ourselves for missing such a simple, but important problem.
This week's biggest problem, though, came from the lab work. My partner and I were having extreme difficulties with the finalization of our first recursion code, and we could not tell at all where the problem was originating from. Therefore, we decided to move on to the freeze code, which we finished relatively quickly, in order to clear our minds of the first code. We ended up staying at the lab a good half hour more than we were meant to in order to finish the code and determine the source of the problem. We were literally at our wits end, until finally, almost as a joke, we decided to add "return" to the end of our code, thinking that it couldn't possibly be the source of our misery. Lo and behold though, our code worked perfectly after this, and we laughed at ourselves for missing such a simple, but important problem.
Sunday, 2 February 2014
Exceptions and raising errors
My work in computer science over the past week made me much more familiar with Exceptions and raising error messages, due to the lecture material, the class exercise, and the lab. Prior to this, I did not have any experience with these things, and so this experience opened my eyes. The irony of course was that, even though this was an entirely new thing to me, I found that I was able to grasp most of the concepts rather quickly, thanks to the slides and other links posted on the class site. I actually found it rather fun to work with the different errors and error messages, as they provided and interesting look into some of the most crucial construction blocks of a good bit of programming.
I did, however, have a short moment of difficulty when attempting to use the "try" method. At first, I was unaware of how the "except" part of "try" worked, and so I would simply "try" a method, without implementing an "except". Of course this created some errors, and it took me a little while of searching the sources provided to finally grasp why the errors were showing up, and why "except" was needed. After learning that it was needed though, and that it worked sort of like an "if" statement in terms of its construction, I was able to use it properly, and finish the code that I was working on.
I did, however, have a short moment of difficulty when attempting to use the "try" method. At first, I was unaware of how the "except" part of "try" worked, and so I would simply "try" a method, without implementing an "except". Of course this created some errors, and it took me a little while of searching the sources provided to finally grasp why the errors were showing up, and why "except" was needed. After learning that it was needed though, and that it worked sort of like an "if" statement in terms of its construction, I was able to use it properly, and finish the code that I was working on.
Subscribe to:
Posts (Atom)