Sunday, 27 October 2013

CSC 148 SLOG for Week 7

         This week we continued to learn about binary trees and nodes and how to implement a tree using a linked list. I have studied linked list before and it was pretty much the same in java as in python. I find linked list very convenient because we only need one instance variable to represent the whole list. The exercise this week was a little painful for me since I kept misunderstanding the instructions and I also forgot to check what internals and leaves referred to, so that I always got errors reported from markus. It was a pretty fun exercise, though it did waste me a long time correcting my stupid mistakes, and it wasn't as hard as last week's which I really enjoyed. However, I did start doing the assignment this week and find it very intriguing. I always like case studies and classes that are not built in such as the grid world case study from eclipse. I think this way it would compel us to think more comprehensively and diligently since there are no convenient library methods ready for use. And this assignment is another typical example of a logical problem that does not require much code. I finished the first part but I'm still stuck on the second because I just can't figure out how to check the RegexTree from the bottom up and how to reference to the corresponding characters in the string. I already drew a detailed tree and analyzed different scenarios but I still can't solve it. I want to leave it for now and maybe ask the professor next week. I feel pretty confident about the material covered this week because I think I have a pretty good logic but not a very good memory, so binary tree is fairly easy to me. The lab this week was also about linked lists which I found no difficulty in. This week I also received my grade for the first assignment and I received a 70 something with a class average of 60 something. I have to say that the grading was pretty harsh since it was already very hard for me to finish everything and make it work while looking at the rubric I saw that you would only get half the credit if you just finish it. I find that unreasonable since not everybody can think in a concise and efficient way now that we are just beginning to program and as long as I was not hardcoding I should get a higher grade. But I did enjoy the assignment a lot and this rubric prompts me to be more efficient in writing code. I recall the exercise last week where I used the maximum of a list of tuples in a list comprehension and feel like I am able to write efficient code already. It's just that large assignments are more daunting so that I can't really think of brevity. I need to pratice and think more about which algorithm is the most efficient. I read the blog by bearw on http://obiwanslog.blogspot.ca/ and felt the same way as he did. I, too, spent a long time debugging because there was just too much to implement but when I got to tour of Anne Hoy and SolvingController it flowed really quickly because I was immersed in the fun of logical thinking. The last part required a lot of thinking and little coding.

Sunday, 20 October 2013

CSC 148 SLOG for Week 6

         This week we didn't learn about anything since monday was thanksgiving and we had midterm on Wednesday. The midterm was okay in terms of difficulty but the sad thing is since I skipped CSC108 I am not familiar with how some of the functions run. For example, I got the first question completely wrong because I thought the minimum of a list of tuples will give you the tuple with the least element but after the midterm I realized that it gives you the tuple with the least first element and if the first is the same for some it looks at the second. I need to work harder with familiarizing myself with python, though I do feel more confident now after several weeks of practice. I should read documentations more often. Moreover, I find the exercise this week incredibly fun. This is the hardest exercise so far and I really enjoyed doing it. Before the exercise I already knew quite well the difference between the three traversals, however I never thought building the original tree from the traversals would be way harder from the other way around, since you don't have a clear sense of division between the root and the left subtree and the right subtree now that everything is in one list. But with two traversals you can find the root from one then the left and right from the other and keep using recursion to order everything. I also remembered to handle the exceptional cases where the left or right subtree is none. I felt a great sense of accomplishment after I finished it, and part b is just a piece of cake compared to a. This whole concept of trees make me reflect on some of the most interesting topics I learned in java. I find trees very different from what we've learned so far since it is not actually a built-in class. It is a useful concept defined by convention. When I studied java before I felt like searching and sorting was very interesting since it was pure logic and there was no existing resource at all, just like trees in python. 

Monday, 14 October 2013

CSC 148 SLOG for Week 5



      This week we learned about the concepts and possible algorithms behind the assignment, however it doesn't really help me since I already finished it last week. The explanation on the Tour of Anne Hoy method was pretty helpful though, since I didn't fully understand the meaning of it when I used it, but now it seems much clearer to me. We learned about recursive data structures in the second lecture and this is something completely new to me. I find it quite rare to learn something that is not a built-in class or function, which was also the case when I learned computer science in high school. Recursive data structures appear to me similar to searching and sorting algorithms, which are important fields but are algorithms and conventions instead of existing classes and functions. This week's lab was essentially all about recursion, which I feel pretty confident about since I used it many times before I started this class because it is just too convenient and too useful, if you can get the idea right. I feel like recursion requires a lot of thinking but very little writing, which is also what I felt when I did the assignment. However, I had a question about how to solve the issue of initializing a variable and returning it at the end using a recursive method since the variable would be reinitiated every recursion. Then with the help of my TA I realized that if I use a for loop with in a recursive method I could avoid this problem since the variable would be returned and the variable with the same name of the previous iteration is indeed another variable and there wouldn't be a conflict, which is something new that I learned.


Tuesday, 8 October 2013

CSC 148 SLOG for Week 4

   This week we learned about the basis of inheritance and how to reuse the superclass's initialization method and also its methods that do not need to be changed. I've already studied Java extensively and inheritance seems pretty similar in python, too, so this was pretty easy to understand. However, I wonder if there is interface in python. I've seen abstract classes in python but not interface yet. Then I searched it up online and found out that python does not have an interface. I thought about the use of interface in Java and realized that it was there solely to ensure that a subclass can inherit multiple interfaces. However python inheritance already covers multiple inheritance so an interface is unnecessary. This improved my understanding of how dynamic python is and how flexible its structure could be. Our exercise this week asks us to write test cases for the classes of quadrilaterals we need to write using the unitttest class, which does not exist in java. So I looked at the documentation and the examples posted on the course webpage, and the professor gave some introduction about what it does so I pretty much get how to write it. This is such a useful tool for testing our code. I should use it more often in the future. The lab this week is also pretty easy; we simply had to write a Motorized and a HumanPowered class and other classes that extend them. I teamed up with Trevor and Charlene this week to work on the assignment and I spent at least 15 hours to finish it. The tour and solving controller part proved to be challenging, but after I realized how to use recursion to call the toah method everything else just flows smoothly. I'm really proud of myself. 

CSC 148 SLOG for Week 3

      This week we learned about recursion and how to use list comprehensions that include recursive statements. I went to the ramp up session for 108 last weekend so now I feel much more confident about the materials we covered in 148. I'm surprised by how you don't need to specify a base case if you use list comprehensions, which is a major improvement from java. I stared working on the assignment and find it really hard. Even though I am pretty familiar with recursion, how to use recursion to move the cheeses requires much more knowledge than my previous experience. I tried to finish the first seventy percent of the assignment but there is some error with my code that doesn't produce the right result. I certainly need to work on that. The exercise this week about exceptions was both hard and easy, hard in that I haven't really learned about Exception before so I don't really know how to write one, but easy in that it's actually pretty simple write once I finished reading the documentation. The lab this week was also pretty simple since it only asks us to write a stack and a queue. However, we couldn't figure out why a stack is more efficient than a queue. I think it has something to do with the fact that stack appends to the end and removes from the end which is the most recent one added while in queue you have to find the first one.