Thursday 27 March 2014

Big-Oh No

The concept of putting things in an order has been established within our minds since we were very young. Maybe we'd arrange our toys according to which one is our favourite, putting them at the top of our toy box. We learned that sorting and ordering things simply made our lives easier, like having easier access to our favourite toys, since they were at the top of our toy box, and we would not have to dig around for them.

Bubble sort, Insertion sort, and Selection sort were introduced to us in CSC108, and it was interesting to see how they worked in terms of sorting lists, and making our lives much easier. I don't suppose we spoke much of the rate at which they were better than each other, but we just accepted the fact that a certain option was better than another in certain instances, and that Bubble sort was never really a good option.

In CSC148, we were introduced to more sorting methods, namely Merge sort, Quick sort, and Tim sort (a hybrid sort, created in 2002, and now used as Python's built-in sorting method). Merge sort and Quick sort are pretty similar to each other, and Tim sort is a mix of both Merge sort and Insertion sort. Not only did we learn about how they worked, but we also learned about their efficiency.

When we talk of Big O, we refer to the run time of the worst case of a function, or in other words, its efficiency. When determining the worst case, there are various factors involved, such as the length of the list, or how sorted it is. Knowing of these factors helps us in figuring out the worst case of a function.

Since I'm not currently enrolled in CSC165, I had to teach myself about the concept of Big O, (for the most part). It took me a while to understand at first, but after a thinking of the efficiency of a few functions, the reasoning clicked and made it much easier and faster to figure out the answer.

For Term Test #2, I looked back on the Sample Test for Term Test #1, since it had a question on Big O. It was in chart form, and those were questions I was completely comfortable with. I had sheer confidence in my skills of determining efficiency. However, when it came to writing Term Test #2, I was not prepared in the slightest for the Big O question. It was a very worrying experience, because it took a while to go through the functions and then explain the reasoning without sounding like I was making it up.

I'm still trying to get better at learning about Big O, and this week's SLOG helped me out a bit, in terms of making me research different sorting methods, and figuring out which ones are better than others in specific cases. I especially liked the interactive displays of some sorting methods, because you could step through the process, and you could see the sorting methods working under different conditions.

Specifically, this is the link I liked the most:


Thursday 27 February 2014

"To understand what recursion is, you must first understand recursion."

The first time I was introduced to anything recursive was during elementary school, when learning about the Fibonacci sequence. I was taught that the rule of this sequence was that the next number was found by finding the sum of the two numbers before it. Therefore, the result was always based on the previous result.

When learning about recursion in Computer Science, it seemed simple enough to understand mentally, but when it came to coding recursive functions, I could not wrap my head around it. I spent some time reading about recursion and looking at examples of recursive code, but I could not reproduce any myself. This was obviously going to be very detrimental to me, because I knew most of the code I would be looking at in the future would require me to know, understand, and implement recursion in order to write more effective code.

A solution I had for my struggle in understanding recursion was asking my friends and peers to tell me the simplest way they understood it. The best example I received was in the form of a present:

"There's this huge gift box, and inside it, there is another gift box, and inside it there is another gift box, and inside it, there is another gift box, etc. In order to get to the present, I'd have to open the first box, then open the next box, and then open the next box, etc. 

To do this with a function, you would have the first gift box be your argument. You would check first if when you open the box, there isn't a box inside, because if it isn't a box, it would be your present. However, if there is a box inside, then you would call your function again, this time with the new box being the argument, and the same process would happen all over again, until you reach your present. 

The action taken next would be based on the result of the previous action. Obviously if there was no next box inside, and you had reached your present, you would not try to open a box. The box wouldn't even exist for you to open it! In the same way, if you opened the box and there was another box inside, you wouldn't just stop and accept that this box is your true present."

This example really made me happy, not just because it involved a present, but because it took something I thought was complicated, and transformed it into a real life situation. I think it's important that I learned how to relate the troubles I have with functions to real life, because sometimes while searching for answers online, I find that they're convoluted in even bigger problems that I have not had experience with yet. This only serves to make me frustrated and disappointed in myself, taking away from the fun experience of Computer Science.


Friday 14 February 2014

"When it rains, it pours."

This is it; the week that the first CSC148 assignment is due. Coincidentally, it is also the week of multiple midterms, quizzes, essays, and assignments… right before Reading Week. Talk about stressful.

I really think that is the hardest part of university. I have never found any exams or tests to be extremely difficult or challenging, but with all of them at once… it gets difficult to focus on one thing when 5 others are at the back of your mind.

Both my partner and I had a lot to worry about besides the due date of the assignment, and it was quite difficult for us to juggle our time. It made us very sad and contemplate if we still wanted to pursue Computer Science if we could not even handle an assignment. With midterms worth 20% - 30% up till Wednesday night, getting frustrated over fixing our assignment was not really a big priority.

That left Thursday; the day my partner and I spent in the Help Center, just using the atmosphere as an inspiration to work on our assignment. We would occasionally ask for help, but really, the Help Center was a place that kept us from getting distracted as much as we would have if we were elsewhere.

This week really helped me realise the importance of time management, and how much I really need to improve on mine. Had I started the assignment a bit earlier, or studied a bit more for my midterms, I would have probably felt much better about my work than I do presently.

Thursday 6 February 2014

Operation "Move the Cheese"

For the first assignment of CSC148, the objective was to implement parts of a step-by-step design of an object-oriented program for a Towers of Anne Hoy game. Initially, I felt like I didn't understand the game, so after some further reading on Wikipedia, I realised it was a lot like the 4 Lions game I used to play on Math Circus, (if anyone remembers that from elementary school).

I was a little bit worried starting out on the assignment because I didn't feel too confident in my abilities and knowledge to write and solve code. I read the assignment handout repeatedly and stared at the files for hours, almost in tears because I didn't even know how to begin. I never felt so clueless and flustered, and I didn't even know what kind of questions to ask my peers without sounding like a complete idiot.

After about 4 hours of frustration, and a good night's rest, I managed to tackle the assignment without too many difficulties.

The lesson I learned from this experience was that even though I was reading the assignment over and over again for hours, and not producing an visible progress, it doesn't mean I'm still NOT making progress. I felt that understanding the assignment before starting any work made the entire process much more easier to tackle, and easier to fix, had I made any mistakes.

Thursday 30 January 2014

from friends import Support

I am absolutely, positively, grateful for the friends I have made because of the CSC courses. Every step I take to improve myself is guided by their support and encouragement. I can honestly say that I wouldn't even be moderately comfortable or successful learning the lecture concepts with solely the Prof and TA; I'd probably be insecure about asking potentially stupid questions, or wasting too much of their time. (I know there are others who feel this way, so put your hands up. Don't be shy!)

I believe that's the main goal of the weekly labs; to meet other people who can help you, and in turn, you can help. It's a great way to build skills and learn new things, because I for one sure need those and find them so useful.

For example, I'm glad to have met and befriended my lab partner. I arrived late on the first day, running from a class across campus, so everyone was already grouped up. Luckily for me, my partner volunteered to be stuck with me, and we've been a pretty good pair since.

What I observe during our lab exercises is that we tend to fix each other's mistakes, and walk each other through solutions we think are right. We usually understand concepts that the other partner doesn't, so we teach each other, which is pretty cool, too. (It gives us each the opportunity to feel smart). We are pretty critical of each other as well; thinking of any possible way our ideas can fail. If we can find faults in our work, it's probably a cakewalk for the TA grading us, right? (We know that because our TA has found tons of mistakes in our code).


Anyway, just to reiterate, I'm so glad that I have so many people to support me through my learning experience. I believe that my success is directly proportional to the number of mistakes I've made. (So accept your mistakes! You're making progress!)

Thursday 23 January 2014

It's OOP! (not poop)

Close to the end of CSC 108, and during the beginning of CSC 148, the topic of interest has been on classes. I didn't realize it then, but I now have the impression that class is a very important concept to know and understand in order to excel in writing beautiful and legible programs.

Although they were seemingly simple to deal with initially, I did encounter a few challenges, (one of them being my mentality; "This looks too easy… It can't be this simple. No way!")

Reading about Object-oriented Programming, (OOP), as well as attending Danny's lectures helped me understand classes a little more.

The development of Object-oriented Programming was to achieve the goal of handling the rapid increase of size and complexity of software systems. Python, the programming language I use, provides features that support Object-oriented Programming, making it an OOP language. Considering that I find Python a little difficult to understand at times, and knowing now that OOP was developed to make programmer's job's easier… it makes me grateful that it exists, or else I would be even more confused.

During Danny's lectures, he explained that Object-oriented Programming makes maintaining and modifying much easier. An example he gave concerned making a subclass of a superclass. This allows the programmer to replace or modify the code without breaking it for others who have been using it prior to the new changes. It also helps make the code easier to understand, and reduces the chance of silly mistakes. I already had some experience with these silly mistakes in CSC 108, for example, when my code was unnecessarily too long because of repeating code, and when I would change the code in one place, and forget to change it in another. This made things very frustrating and stressful, but I'm glad I made those mistakes, so I could learn from them.


I look forward to learning more about Object-oriented Programming, because it's such a blessing in terms of making my programming life easier.