Well another week of CSC148 has passed and we did even more recursion in both the lectures and the labs. Not saying it's a bad thing since recursion is a very powerful tool when it comes to programming so let's get a little detail on what we did. In the lab, we looked at some more codes involving recursion and have to trace the code running on 3 different cases. The interesting thing was that in each case following, the previous case appeared and so we just used that value and subbed it in. Afterwards, we actually created our own recursive code and it was a good experience creating our own base cases. The first one we had to create 2 bases cases, where either it would be the value we were looking for or the value is a null. This took a while and I needed to ask the T.A. for a bit of help but it wasn't that hard once he told me about making the 2nd base case since I had checkers in my previous code.The second one was just creating a list from another list and the base case was just when the value was not a list so this example was easy and was quickly finished.
Now in our lectures, we looked at a similar example to the Tower of Hanoi but dealing with cheese. In High School, when we were dealing with recursion, not only did we look at the Tower of Hanoi, but we had to create a program similar to how it worked. The way that the professor taught us in the lecture however was slightly different and seemingly much more simpler just moving everything on top of the bottom piece to the middle and finally getting the bottom to the far side just by using constant recursion. It was pretty confusing at first but after reviewing it a bit more and listening to the professor explain how the recursion in it worked, it made a lot more sense. Afterwards we looked at naming and where python looks for the names of a variable or method. We worked with private and public variables in Java and it's slightly different in the sense that I don't recall ever having declared something was global or non-global since public and private did that. Other than that, the tracing of where "spam" in the lecture came from was pretty easily understandable to know whether or not "spam" was passed to outside of the method "scope_test".
Well this ends another SLOG for CSC148... looking forward to the reading week break but first... I have to worry about assignment one and the upcoming midterm for chemistry...
No comments:
Post a Comment