Friday, 4 April 2014

Week 12 - Wrapup

So finally, this was the last week of the course. We didn't learn too many new things this week. As the title suggests, it was basically a review of what we learned throughout this course.

We had only two classes this week, and Dan talked about the structure of the final exam on the last class. I must say, it seemed very useful.

Moreover, we had to submit Exercise 4 this week. Like the other exercises, this was pretty easy as well. But I did need a bit of help at the beginning in trying to think of the algorithm for the max_node method. I went through our TA, Bryan's slides on binary search trees. They were extremely useful. Furthermore, I would like to add that Bryan is very good in explaining, and I found his lecture earlier this semester very helpful.

Just before writing this slog, I checked and found that all my tests for Exercise 4 passed! So this makes me get a perfect score on all the exercises! Yay!

We are now at the very end of the course and the only thing remaining is the final exam. The words "final exam" seem to scare me a lot because I have a feeling they are quite harder than the term tests.

For now, I have to keep calm and study, and make the most of the days before the exam. My main plan is to solve the past term tests and exams, go over the exercises, and solve the questions we were given on the tests this term. I don't really think it's a good idea to go over the readings or lecture slides anymore at this stage because we know everything by now. And all we need now is practice!

That's all I have for this week and this semester. I haven't really seen much feedback from other people till now. Please comment below if you have anything to say about my slogs. It was fun taking CSC148 this semester. Hope to see most of you in CSC207 and other courses in the future.


Good bye CSC148!

Week 11 - Test 2

This was the 2nd last week of the course, and there was nothing new taught to us. This week was fully dedicated to Test 2.

On Monday, we went over some sample questions and solutions for preparation of the test. I personally found these very helpful.

To me the test was not very difficult, although I managed to get a poor mark. I believe I could not keep myself cool during the test, and that is what has caused me to do poor.

I did practice quite a lot from the past tests and exams before the test. In fact, I even solved the last question on the test (implementing an iterative version of the append method for the LinkedList class) quite comfortably at home. But however, I failed to deliver in the test. Actually I did a very small mistake in the loop in the answer to the question, and had to lose 4 out of 5 marks for that.

Overall, even though I did quite bad in the test, I am not too unhappy with myself because the mistakes I did were very pretty small. And I believe, this will make me even more careful and focused during other tests/exams in the future.

This week was not a very challenging one, and it ended with Dan going over the solutions for the test.

As Dan said, Exercise 4 (the final one) will be posted very soon. Looking forward to that and the final week of the course!

Week 10 - Sorting

This week we learned about something which we came across before in CSC108. Yes, we learned about different sorting algorithms.

We were introduced to different kinds of sorts (i.e. selection sort, insertion sort, bubble sort, merge sort, etc) last semester in CSC108. But now, we are learned about the implementation of these sorts and their run-times. At the beginning I seemed to enjoy the topic, but soon I realized that it is quite complicated. The main difficulty I faced was to keep up with the lecture. I had problems understanding the implementations of some of the sorts, and soon I got lost while Dan was speaking. This happened to me several times during the lecture this week.

I am currently reviewing the lecture slides to get a better understanding of the implementations of the different sorts. All the algorithms look quite complicated, especially the ones for quick sort and merge sort. I think I need to go to Dan during his office hours next week to get further help.

To be honest, this week has not been good for me. I couldn't make use of the lectures and failed to understand a lot of things during the lecture.

However, I started and finished part 2 of Assignment 2 which was posted last week. It involved a lot of recursion, and I am proud of myself that I finally got a hold on recursion!

Oh well, the marks for Assignment 1 got posted earlier this week, and I did pretty well! It was a great source of inspiration for me to work harder on Assignment 2.

So, finally we are done with both the assignments, and now it's high time that I start studying for the test which is coming up next week.

Hoping for the best!

Sunday, 30 March 2014

Week 9 - Complexity

Well, we just finished the 9th week of the course, and started a not so complex topic called complexity. This topic deals with the efficiency of functions, methods, and thus programs.

I found this topic quite interesting, especially observing the different run-times of different functions, and finding out the reasons for their difference even though they have identical inputs and outputs. I would probably say this is the most interesting topic I came across in this course so far.

The following is the maximum_segment function and an image of a lecture slide which shows how the different terms in T(n) grow for the function, as the number of elements n in the list L increases:

def max_segment_sum(L):
   '''(list of int) -> int
   Return maximum segment sum of L.
   '''
   max_so_far = 0
   for lower in range(len(L)):
      for upper in range(lower, len(L)):
         sum = 0
         for i in range(lower, upper+1):
            sum = sum + L[i]
         max_so_far = max(max_so_far, sum)
    return max_so_far



This was particularly an interesting observation, as even though I came across this function before in CSC108, I never thought about its behavior or run-time for different numbers of elements in the list.

Overall, this week went pretty well for me. There wasn't much challenge I had to face. However, the lab was not that easy; we had to deal with some nested functions and recursion. (If you are a freshman in Computer Science, this should sound scary.)

There is more one more positive I can take from this week; I successfully completed and submitted part 1 for Assignment 2. It was actually super-easy. I just tended to think in a too complicated way at the beginning, and thus confused myself. I must say, it was a great idea to include a part of the assignment solely for design; we often spend hours to make a program working, but we rarely think of our design of the code. This part of the assignment definitely helped me in learning to think and come up with design which has fewer lines of code. Thanks to inheritance.

Okay, I guess I have said everything I had in my mind for this week. Hoping for a wonderful weekend and a great coming week!

Monday, 24 March 2014

Week 8 - Binary Search Trees

This is the end of week 8, and we just got introduced to a new kind of trees, known as binary search trees. I like trees, and probably Dan knows it, and that's why he is teaching us more trees!

On a more serious note, we just finished a wonderful week where we learned the structure and use of this particular kind of trees. To be honest, there isn't much to learn about their structure. The main learning is in making useful functions or methods to perform particular tasks on/with these trees.

I am really enjoying dealing with these trees! I know some people are really hating it (but I guess I am eco-friendly). Some of the functions that were solved in class were quite interesting. Finding the height of a BST, and finding whether a value is in a BST are two which I enjoyed learning. However, I found the method for deleting a node quite tricky, and can't solve it by myself yet. I seemed to understand it during the lecture, but soon forgot when I came back home. Write before writing this slog, I did some searching on Google and found an algorithm which looks similar to the one that Dan showed us. I hope this will work once I code it. I reviewed the algorithm on the lecture slide, but for some odd reason that seemed quite confusing.

Overall this week was not a bad one. I experimented a lot of things this week with trees in general (not just BSTs). I even made a method which returns the number of leaves in a tree:

def num_leaves(t: Tree) -> int:
    if t is None:
        return 0
   
    if t.children == []:
        return 1

    count = 0
    for child in t.children:
        count += leaf_count(child)

    return count

I am also trying to implement a method which will find and return the average of the values of whole binary tree. But, I am still struggling with that.

Okay, on a different note, I just saw that the handout for Assignment 2 got posted. After reading it for around 10 times, I am yet to understand what we exactly have to do in part 1. I probably have to go Dan's office hours for this.

As we wait for the results of Assignment 1, it's already time to get started with Assignment 2.

Hope the coming week will treat me well.

Saturday, 22 March 2014

Week 7 - Linked Lists

We are back to work after the reading week. It was a nice and relaxing break. Now its time to get back to studying againg as we already started a new topic - Linked Lists.

Like last week, this week's topic was quite easy as well. I have been keeping up with the readings, so I am not facing much difficulty in understanding the lectures. Dan showed us two ways of representing the Linked List ADT; using list of lists, and by creating classes (nodes and references). I personally prefer using the nodes and references representation because it is simpler to use, and looks nicer in the shell.

I enjoyed attending the lectures this week; they were fun. I particularly enjoyed the append method that Dan solved in lecture using recursion. There is also an iterative solution to this method, which I will try to solve by myself over the weekend.

Our first test was held this Wednesday in lecture, however, I was extremely unwell and therefore could not attend it. Many of my friends later said it was not too hard, so I can consider myself unlucky.

I believe this week was okay in terms of difficulty of the topic. The lab was not too complex as the last one. In fact, it was fun! I enjoyed doing it.

That's all I had for this week. Now looking forward and hoping for a wonderful coming week!

Tuesday, 18 March 2014

Week 6 - Trees

We are into week 6 of the course, and this week we have been introduced to a completely new topic - Trees! Nope, not the ones that we see around us. These trees are upside down. They have their root at the top, and the leaves at the bottom! Sounds interesting, right? -- Yes it is!

This tree data structure is relatively easy to understand, and does not require much deep thinking. It just took me around 15 minutes to understand the basic features of a tree. I must say, the reading that was posted for this week was very well designed, and was to the point. The lecture and lecture slides complemented the readings nicely as well.

This week was not a very challenging one. The readings and the lecture material all were quite easy to understand. However, the lab was a bit tricky/confusing. I did not like the way of using comprehensions for coding. Though sometimes it may be efficient and require less lines of code, I found it quite challenging to interpret and use. I would therefore prefer the way we have learned so far using loops.

As I said, apart from the lab everything went pretty smooth this week. The only other thing which seemed a bit tricky were the tree traversals. I seem to get lost while traversing by myself, and have to start all over again. However, I believe this is because I am still very new to the topic. A bit more of practice is all I need to get a strong grip of this topic.

Oh, and finally I am done with Assignment 1. I am extremely happy that I finally finished it! It's a feeling of great relief and contentment.

Following is a screenshot of the output from my tour module, for eight cheeses. As Dan showed in lecture, 33 is the minimum number of moves for eight cheeses. So I am right!


Woohoo!