Saturday, 16 April 2016

Week 12: Final Week


This was the final week -- congratulations to everyone who made it! It has been a long and stressful term, but I managed to make it through. We were introduced to new topics these last two weeks. I have not yet grasped all the concepts, so there will be lots of reviewing for me to do. The last stretch of CSC148 focused a lot on efficiency, which I appreciated. I enjoy learning about what makes one code more efficient than the other. I remember going over all the different sorting methods in CSC108, so I was familiar with things like "bubble sort" and "insertion  sort".  As well, it seems to me that lists are very inefficient, while dictionaries and sets are much more efficient.

We were also introduced to hashing, which I sort of knew through Assignment 2. I remember when I tried to add puzzles into a set, I would get an error saying that I cannot add an unhashable type. After doing some googling, I found out that unhashable meant a type was mutable. Additionally, when we were introduced to aliasing, I realized that I had encountered a problem concerning aliasing in Assignment 2 as well. I remember when I was trying to create a copy of list with internal lists, it was only copying the outer list and not the interior ones. That was when I realized that I was creating a shallow copy of the list, rather than a deep copy.

I had a fun time taking CSC148. Although I had a lot of difficulties during the midterms I hope I can make a come back for the final! Goodbye and good luck to everyone on the final!

Thursday, 31 March 2016

Week 11


This week I revisited my slog entry from week 5. It is very evident that I have improved on my visualizing skills. During week 5, I was not visualizing what was happening for class LinkedListNode and LinkedList. As a result, I was not seeing the bigger picture. I knew how to walk through the LinkedList, but I had troubles with inserting values into the LinkedList. Therefore, I believe I have developed my thinking in the way I look at classes. I have learned that it is important to visualize what the class does and to draw out what happens if possible. I never drew any visual pictures of classes before until we were introduced to trees. That was when I realized that it is very helpful to draw a visual picture of the classes.

In addition to realizing the importance of visualizing, my perception of what computer science is has developed in that I see more of how computer science is applied to real life situations. In CSC108, it was all about how to get the right output, but in CSC148, we learn how to build classes to take on certain characteristics. I remember not understanding the point of a linked list. However, now it makes much more sense, in that it takes up much less memory space, especially if we're thinking about a list containing a large amount of numbers.

Thanks for reading!

Saturday, 26 March 2016

Week 10


This week was tough for me. My term test 2 marks were a hard blow for me, and I was swamped with other work from other classes. I felt like I was falling behind everything. I was so confused with this week's lab, which is a shame considering I had been doing so well up till now. I found it hard to estimate of a function's run time is O(n2) or O(nlogn). I will definitely have to review this concept more before the final.

It was a close call for Assignment 2. I almost thought I wouldn't be able to finish it on time because I was stuck on implementing depth_first_solve and breadth_first_solve for a very long time. I eventually figured out how to solve breadth_first_solve by using the deque that was suggested by instructors. I then followed the general format of the levelorder_visit function we went over during the lecture on traversing general trees, as breadth_first_solve travels in levelorder. Once I implemented breadth_first_solve, I ran all of the puzzles to see if it worked and it did. But I found that the running time was very long. I then saw that people were saying to use sets on Piazza. At first I wasn't sure how to use them as I kept getting a message saying I cannot add an unhashable type. I realized that class PuzzleNode was not immutable, so I switched to using the string of each puzzle contained within each node. This increased my running time by a significant amount, much to my surprise.

After implementing breadth_first_solve, I was once again stuck in a rut with depth_first_solve. I wanted to use recursion, since it seemed easiest in my mind. But the problem was that my function would only recursively travel through one branch of the tree and stop. I did not know how to fix that problem. Thankfully, I read a pseudocode online that used a queue like breadth_first_solve, and then everything made sense to me. I didn't realize that I could also use a queue like in breadth_first_solve, but all I needed to change was the way I added each PuzzleNode into the queue. In breadth_first_solve, after visiting a node, I added all of its children/extensions to the back of the queue. Then in depth_first_solve, I added all of the children/extensions to the front of the queue. I still can't believe that was all that needed to be changed between the two functions! Fortunately, I finished the assignment with 35 minutes to spare. Now there are no more assignments to complete! Hurray!

Thanks for reading!

Monday, 21 March 2016

Week 9


This week brought in the long-awaited second midterm. As my luck would have it, the TTC service was suspended from Sheppard all the way to Bloor-Yonge right at the time that I was taking it. As a result, I was late by 15 minutes. I was having a mental breakdown, and I wish I had more time but I guess that's life. But it's just frustrating that things like this happen at the most crucial moments -- especially since I performed poorly on the first midterm and this was my chance to redeem myself. I know I made a lot of stupid mistakes, because I keep forgetting that binary trees are different than regular trees, in that binary trees have a max arity of 2.

As for Assignment 2, I'm still stuck on how to implement the depth_first_solve and breadth_first_solve functions. I am having difficulties finding a way to link the PuzzleNodes together. It is very difficult, as the children parameter for class PuzzleNode is a list of PuzzleNodes, but each PuzzleNode should only have one child and they all link together until the arrival of the solved puzzle. I'm also not sure what happens when there are no more possible solutions, and how to stop the endless loop of extensions when that happens. Hopefully I'll be able to finish Assignment 2 soon, as I have a lot of big projects due soon from other classes.

See you next week!

Sunday, 13 March 2016

Week 8


This week was the final week before our second midterm and I am feeling more and more anxious about it! I really want to redeem myself but I am still not confident in my skills. I find the concept of binary trees and traversals confusing so I have some reviewing to do. However, I do feel confident about the concepts of the general tree, as I worked through all the functions/methods in the additional exercises of this week's lab. The only thing I had difficulties with was the levelorder_visit function. But after Professor Danny Heap went over the levelorder_visit function for binary trees, I knew how to implement the function for the general Tree class.

I spent the majority of this week working on Assignment 2. I've worked out most of my code for the puzzles, but I am stumped on how to implement the depth_first_solve and breadth_first_solve functions. I think the problem is that I don't quite understand how to utilize the PuzzleNode class. There is a puzzle parameter and a children parameter, which I understand, but I don't know what the purpose of the parent parameter is. I'm also confused why the parent parameter is behind the children parameter. At the moment, all I'm sure is that the depth_first_solve function travels through the puzzle tree in preorder, while breadth_first_solve travels in level order.

I would say the week ended off on a good note with the lab. I found it very easy, which I hope means that I have been improving on my recursion skills. I'm also very happy with my Assignment 1 mark, so hopefully things will only get better from here on out.

See you next week and good luck to everyone on the midterm!

Thursday, 3 March 2016

Week 7: Recursion

This week was all about recursion. My problem with recursion is that I spend too much time thinking about how to implement the recursive calls. I hope I can improve upon my speed, as I need to think fast for the upcoming midterm. Speed has always been my weakness. Both in high school and since coming to university, finishing tests under a time constraint has been a struggle. But practise makes perfect, and I will redeem myself!

I worked on the lab exercises this week. I found it very easy to write the first base condition, where it does not involve recursive calls. But the else block was confusing because I did not know how to incorporate the recursive calls. I found myself just writing the code like it was not recursive. I had the biggest difficulty with the function, max_length. The problem for me was to find a way to accumulate all the lengths of the sublists (if there was any) and return the max. I kept getting an error saying that you cannot find the length of an int and that was when I realized I had to make sure to find the length of the element I am iterating over only if it is a list.

The examples from the lectures have helped me a lot. I make sure to go over each example by myself after the lectures and write them out on paper. This allows me to make sure I understand what is going on. Moreover, tracing the code by writing them out also helps a great deal in understanding each step. I was particularly confused with the nested_contains function we went over in class because of the way it used the any method. The solution worked out in class was:

return any([nested_contains(x, value)
                if isinstance(x, list) else x == value
                for x in list_])

By tracing the code using the given docstring examples, I was able to understand how this code works. It iterates over each element in list_, as well as the elements of any sublists. When the element is not a list, it checks to see if the element equals the given value. If it does, it returns True. The any method then sees that there is a True, so it also returns True. After understanding this example, I felt a little more confident in my knowledge in recursion.

Sunday, 28 February 2016

Week 6


This week I finally finished Assignment #1. Yay! I found the most difficult part of this assignment was fully understanding what the instructors wanted and to analyze the client code to see what the final output should be. The more I went on Piazza, the more confused I would get. I don't think I was the only one, because a lot of people were asking the same questions over and over again and it seemed a lot of misunderstandings were created. The thing most people were confused over was in regards to which functions/methods we had to write examples for. Some people answered that it was only for the functions/methods that we had to write the docstrings for, while others answered it was for any function/method that did not return None. I ended up just writing for all the functions/methods that did not return None, but even now I am unsure as to what is really required.

I believe through this assignment I really got a taste as to what it is like to design your own classes based on reading through docstrings and client code. I think it was a good exercise for all of us to think more like computer scientists. I believe my code (at least most of it) is correct, as I got the correct output for the output_small.txt we received. I can only hope that my style was good. I am really praying that my mark will be good for Assignment #1 because I really want to boost my mark after a very disappointing midterm. The only thing I am worried about for the assignment is that I had almost no helper functions/methods at all, which I found peculiar. I just never saw the need for them but I remember when I did assignments in CSC108, I always wrote helper functions, so it felt strange this time.

The lab this week was very easy. I finished it very quickly and it was very straight forward unlike the last one, which got me really confused. We were introduced to recursion this week. I have always heard that recursion is very difficult, so I feel a little anxious for what's to come. So far things are straight forward and I am understanding what is going on during lectures. But I have not practised writing my own recursive functions, which is probably where things will get difficult. It is one thing to understand something when going over the solutions, and another when implementing your own recursive functions. However, I believe with practise things will get easier, and I will perform much better on the next midterm.

See you next week!

Sunday, 14 February 2016

Week 5


This week was the week everyone was dreading -- the week of midterms!! I was very nervous because it was my very first midterm this semester. Unfortunately, I did not do as well as I had hoped, mainly because I did not manage my time very wisely. I spent too much time on the docstrings, and I did not map out my time very well. The thing that happens every time I write a test is that I think too much, which makes me confused and I start to panic. But I learned my lesson this week, and hopefully the next midterm will go more smoothly. I am also worried about the people who could not write their test because of the false fire alarm. Hopefully things will be resolved in a fair manner.

I felt extremely stressed this week because I had so many things due at once, and because of that, I did not have a chance to do the lab beforehand. I always finish the lab beforehand because I usually take more than 2 hours to make sense of it. I was confused with the insert_before method for this week's lab, as I did not know how to set the next node with a new value and append the remaining nodes. It was only after the quiz that I realized I just needed to create a LinkedListNode, because it allows for you to set the next nodes. As a result, I did not finish the lab and I messed up on the quiz. Next time I will definitely do the lab before the day of the quiz.

Fingers crossed that I will actually make use of this reading week to catch up and get ahead in all my homework and studying! I still have quite a bit to do for Assignment 1. I am still confused with how all the classes tie in with each other but I'm sure I will sort things out by the deadline. Professor Danny Heap said to look at the client code to figure out how we should format our str methods for our classes, but I was still unsure when I looked at it.

See you after the break!

Saturday, 6 February 2016

Week 4


Another week has come and gone with midterms fast approaching. No new concepts were introduced, which was a relief. I am still feeling a little bit confused over the difference between private and public attributes/methods. This makes me feel a little anxious over the upcoming midterm next week. Professor Danny Heap mentioned that the previous midterms will be the least helpful to us, but I will still work through them because I found them very useful in CSC108. I am also a little wary about inheritance so I will have to review that before the midterm.

This week's quiz was very simple. I appreciated how the question was based exactly on the list_queue function we wrote in our lab. The lab this week involved writing client code and unittests. I found it fairly straight forward, considering class Queue did basically the same things as class Stack. The only thing I did not quite understand was the part where we had to create unittests. Although I followed what the testqueue file did for creating unittests, I did not completely understand all the tests that were used. I created unittests in CSC108, but the wording and functions created were very straight forward and were used to test functions, not classes. For example, I did not know what "clean up" meant for the testDown unittest. I hope we will learn more about unittests in class, where we will be given guidelines as to how to create them.

I believe my biggest struggle so far in CSC148 is deciding how to structure and format classes in an efficient and cohesive way. I have trouble designing the classes under a time limit and so I hope to become more quick with structuring them. I have a feeling after I complete Assignment 1, I will become more adept in creating classes.

Speaking of which, I finally started Assignment 1 this week. In my opinion, the most difficult part of doing assignments is reading through the assignment outline because it is so tedious. But after understanding the context of the assignment, things get much more interesting. I have not gotten very far through the assignment, so nothing too confusing has popped up yet.

Thanks for reading!

Wednesday, 27 January 2016

CSC148 First Impressions


Hello! Welcome to my CSC148 SLOG. This is where I will be writing weekly posts about my thoughts on this course.

These first few weeks seem to have gone by very quickly. I am thankful that I took CSC108 last term because most of the material covered so far has been covered in CSC108. At the moment, I prefer the format CSC108 took on. The thing I liked the most about CSC108 was that students learned the course materials before the week started through lecture videos posted online. I am someone who learns material slower than others and so I prefer to have some prior knowledge of the material before lectures start. For example, when we were first introduced to the idea of inheriting attributes and private methods, I felt very confused and everything seemed to be going too fast. I would have liked to have seen some videos like in CSC108 prior to the start of the week.

Last week I also attended my first lab. This was where I started to see the differences between CSC108 and CSC148. In CSC108, we were given exactly what the instructors wanted when building classes, while in CSC148, we students are given room to decide how we want to build and organize our classes. This does make things a lot more challenging, but it is important for us to begin to think more like computer scientists.

Overall, I learned a lot more about style and how to avoid writing duplicate code during these past few weeks. Additionally, I have learned how to be more efficient with my code by using list comprehensions. I hope to implement all this newfound knowledge in Assignment 1.

In short, I am enjoying CSC148 and hope to learn more things and improve upon my skills.