2 weeks or so have passed since the last SLOG since I went on vacation with my family and sadly had no access to a computer to do this but anyways here's my SLOG about what has happened so far.
Assignment 1 was due recently and man was it tough. The first few parts were pretty easy as it was just creating methods for the TOAH GUI to play properly but when it got to the recursion part, I was stuck for a long time. I wasn't exactly sure how to approach it but after a bit of digging around and getting a bit of help from the TA's, I learned that the best way to deal with the 4 stool recursion was to use both the formula given to us during the lecture for solving for i in recursion and using that with what we already knew about how the 3 stool recursion worked. Overall the assignment was fairly challenging but now I also see how powerful recursion is.
Now moving to what we learned in this week, we finally began looking at tree structures. We learned a few terms that correspond to what a tree is such as a node but what a tree is more or less is a set of nodes that only have one "parent" node or a node that it branches from. Each path down a tree is unique and no nodes will have children that are connected to nodes further up in the tree or in other paths. We also looked at a few methods that go with trees such as finding the height of tree or longest path length and how many nodes there are in a tree. Tree structures are a great way to see where something came from, such as a program having a "parent" program where its functions are derived from and this helps with tracking down what is happening in a program as well if you trace the path down each node to see what function they are adding on.
Well, that's another week of CSC148, only 2 more midterms to go... and one of them being CSC148. Hopefully I'm prepared for it and do well. There's gonna be a lot of gaming after those 2 are done...
Saturday, 22 February 2014
Sunday, 9 February 2014
Even More Recursion...
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...
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...
Sunday, 2 February 2014
Recursion and Subclasses
Well, another week of CSC148 and boy were sub classes a pain. Actually I had learned about sub classes back in high school and how they could use the functions of the class they inherit from but it was slightly different since I learned how to do this in Java. There are a few small differences on how inheritance works but the idea is more or less the same. The sub class has all the same attributes as the class it inherits from and is also able to use any of the functions created for the master class. In addition, these methods can be slightly modified so they perform different thing when working with a specific subclass. For example, in our lab we made a Vehicle class and a subclass Car. The Car sub class could have used the method to get somewhere but it could be modified such that a car uses the fuel efficiency x2 in order to get to where they wanted to go. Overall sub classes are extremely useful since the methods do not need to be recreated for each subclass since they inherit it from the master class and they can have their own methods that the main class cannot access.
Now, moving on to recursion, it's about the same as what we did in high school as well. In high school we traced functions until we had reached the "base case" or in other words, when the recursion should stop and you begin going back up from the recursive method you went down. It's a bit weird now that we have to look at one case and then when we deal with a different case that contains the old one, we use what we got before but looking back at it, it does appear to save a lot of time when we get into much bigger cases since it's broken down into things we've seen already. I actually plan on going through a few more examples of recursion to refresh my memory a bit and apply what we learned in the lecture about looking back on old examples.
Well that's about it for this weeks post... now I'm going to head back to study for my physics term test coming up pretty soon...
Now, moving on to recursion, it's about the same as what we did in high school as well. In high school we traced functions until we had reached the "base case" or in other words, when the recursion should stop and you begin going back up from the recursive method you went down. It's a bit weird now that we have to look at one case and then when we deal with a different case that contains the old one, we use what we got before but looking back at it, it does appear to save a lot of time when we get into much bigger cases since it's broken down into things we've seen already. I actually plan on going through a few more examples of recursion to refresh my memory a bit and apply what we learned in the lecture about looking back on old examples.
Well that's about it for this weeks post... now I'm going to head back to study for my physics term test coming up pretty soon...
Subscribe to:
Posts (Atom)