Tuesday 5 November 2013

SLOG #5: Assignment numero 2 and Sorting

Today's SLOG will include updates as I progress through assignment 2. I acknowledge it would've been way better to finish it before now, and I have thought about it a lot, but now we've arrived at due date, and it's crunch time.

But first, since procrastinating is usually one of the things I'm better at, some quick words about sorting, which was the topic this week. I have worked with sorting before, but it's mostly in fuzzy memories of the computer science course I took in eleventh grade, and I distinctly remember using "bubble sorts", even though I can't remember how a bubble sort works. So far, the material this week has made sense and has seemed somewhat familiar, however, I don't think I ever used recursion to implement a quicksort, and the run time thing is new-yet-not-new to me, which has a bit of an interesting story behind it. Two Fridays ago, I had the opportunity to go to the Waterloo Google offices, and during the visit, we got split into small groups for mock interviews. I was with mostly 3rd and 4th years from uWaterloo, and the engineer from google posed us a simple programming question that he made increasingly complex everytime we came up with a solution (after the first revision, I just stopped contributing).

At some point, he asked us about the different run times of the algorithms we had and sstarted talking about "big O-s" and I had no clue what was going on. The week after that, it came up in my CSC165 class as we progressed into the algorithms chapter of the course, and finally, this week, it all sort of got tied together, so it's kind of nice how that worked out.

Tomorrow will also be the last class before our next test, which I admit I'm a little nervous for, in case I need to make up for abysmal performance on A2. Luckily, the fall break will ensure I have ample time to mentally prepare myself.

Now, I will endeavor into the world of trying to desperately finish assignment two (interrupted by brief breaks for a) attending the tutorial for this class and b) attending 165). I have become the sort of person who likes to work on my wall, so here's a nice picture of what I've been looking at for a few days:


UPDATE: 11:21PM

Okay, I know I said "updates", plural, but here's the only update on the assignment: I'M DONE. I think. Kind of. I'm like, 80% confident it works. I couldn't make updates (plural) because I was too busy actually doing the thing, imagine that.

The amount of stress this assignment caused me is proportional the the number of empty coffee cups from Rezkinoff around my room (5). What have we learned from this assignment? Well...
Remember when Danny said at the beginning of the semester that his goal was to make us all love recursion? I scoffed and rolled my eyes and silently protested such a repulsive idea.

I was wrong. So very wrong.

I love recursion.




Wednesday 30 October 2013

SLOG #4: Binary Search Trees

I personally think binary search trees are pretty darn neat.

Binary search trees are binary trees in which the left subtree of a node only contains values less than that of the node, while the right subtree contains values that are greater. I'm sure there are lots of ways this is a useful and efficient way to store information, but I think it's beyond me at the hour of 12:17am to come up with a practical application. Mostly, it's a great way to store a whole bunch of sorted keys, and you need to be able to easily locate the highest and lowest stored value or something.

I take back everything I said about this being a hard computer science week. I believe the entire exercise took me a grand total of ten minutes. I'm finally at home in an area where recursion is forbidden. I just need to donate several hours of my tomorrow and Friday to assignment 2, and I will proceed to enjoy a relaxing weekend of having to work on other stuff. (This is assuming I do not procrastinate on assignment 2. I am currently taking a very optimistic viewpoint.)

Tree structures are just becoming more and more comfortable for me as we continue to move forward. I shall eagerly await the results the automarker will provide me with on exercise 6, so I can find out if the towering ten minutes spent coding was time well spent. That was also the last exercise to complete for the term (I think?)! From now on, the remainder of my Friday afternoons will be blessed and free!

Monday 28 October 2013

SLOG #3: I Need To Write More SLOGS

On this fine Monday night, I have decided to do a late blog entry on the past week or two.
Last week was one of those weeks where I spent every minute working on computer science-related stuff cursing the computer science-related stuff that needed to be worked on. Have I ever mentioned my heavy dislike for recursion? However, I did notice upon working on Exercise 5 that I am a lot more comfortable with it, and I'm sure my progress with the subject (the fact that I can now actually use it) would make my high school programming teacher very proud. The lab last week, however, was a complete disaster. It was two hours of brain-hurting unproductiveness, and resulted in my trudging back to the lovely Morrison Hall to collapse unceremoniously into bed. It was probably the most frustrating lab period I've ever had, and to be honest, I still haven't had time to go back and work through it in its entirety because of my full time occupation of being a U of T student with 4 other courses to keep on top of. (Today, I heroically finished my MAT137 problem set 45 minutes before it was due)

Nevertheless, I think I managed to grasp everything in the course thus far. Binary search trees, however, make me crave an advil and a good lie-down. I imagine it will be another head-spinning tutorial this week, and the exercise will be one of those things that requires a whiteboard, a large coffee, and 6 hours of my attention. On top of that, with the assignment looming ahead (that I really need to start on), it's safe to say I'll get to spend a lot of time focusing on computer science this week (and on my birthday weekend!). I guess as a computer science major, however, I can't say I didn't sign up for this.


Friday 18 October 2013

SLOG #2: Exercise 4 and Midterm

It is 12:03 am on October 19th, and exercise 4 has forced to to admit defeat. Based on the past 6.5 hours of my life, I am able to ascertain that the best way to make me feel really dumb really fast is to present me with anything that is nested/recursive. On one hand, I have learned a lot about binary trees, understand them and can manually transverse them with extraordinary ease, and can impress my family with really smart-sounding terminology and explanations. On the other hand, I want to rip all my hair out and fall into a ball because that was the most stressful 6.5 hours I've had in a while, and my solution for part b still doesn't work (and even though there's 20 minutes left before markus actually takes it as late work, I'm so absolutely upset and tired over this whole ordeal, that I just don't care, I absolute cannot right now)

On a kind of nicer note, the midterm earlier this week wasn't bad at all, the most worrying thing about it being that I think I may have misinterpreted one of the questions, because in hindsight, I wrote about 1 line of code for a 15 mark question, and I really question why I thought that was an okay thing to do at the time of the test. So I'm anxious to get the mark for it back, but that's alright, I'm not too concerned because I'm too busy being concerned about midterms that I haven't written yet.

All in all, I learned lots about computer science stuff this week thanks to studying and the 6.5 hour exercise 4 induced hell I just endured, so it was an educational week for the subject despite not having any class, and the CDF labs being down during my tutorial. I hope I never have to use this stuff again (which I know I will, the struggles of comp sci).

UPDATE October 22nd:

Disregard any confession to failure/defeat above, apparently the brute force desperately applied to part b of the exercise managed to succeed for all but one test case, and I'm a python god.

Tuesday 15 October 2013

SLOG #1: Recursion and Object-Oriented Programming

To start off this illustrious blogging assignment (a little late, as it's now week six of the academic year), let me start by saying this is the weirdest computer science assignment I've ever been given.

This has been my first time using Python, though I come from a pretty in-depth Java background. Object-oriented programming is kind of my jam because of that prior experience, and as opposed to finding it particularly challenging, I've found it to be a comfortable and familiar place for me to work in this strange language where you don't even declare your variable types (which, by the way, was the greatest struggle to overcome during the first exercise).

Object-oriented programming revolves around the idea that your code for a class is essentially the blueprint for an object, and these objects have their own variables and fields, which "describe" the object, and methods/functions that can change, access, or perform tasks with the objects created by that same class. Again, coming from a java background, I find object-oriented programming to be a lot more organized and handy than anything else. It is a handy and useful way to be able to create objects that can interact with each other, and to do things that would otherwise be unnecessarily complicated without object-oriented code. Different objects can interact with each other, which again, is probably the preferable way of writing more complicated and user interface-centric code. For example, if you wanted to create a simple tic tac toe game, you could create a class for the grid, the x, and the o, and there would be code within those classes to create the objects, visually represent them, and then have them interact with each other.

Recursion, however, does not give me the warm and familiar feeling of being right at home. It didn't make sense when I was coding in Java, and still makes very little sense to me now. When I start on a recursive problem, initially, I start thinking, "oh, yeah, this makes sense, I can think this through no problem!"

Except then I start thinking too hard, and I confuse myself, and get frustrated, and oh god everything goes downhill from there. Ways to remedy this? I plan on spending a lot more time on a very useful website: http://codingbat.com/python

Codingbat is a coding practice website my high school computer science teacher introduced me to, which was a huge help when I was learning java. It gives practice problems for different programming ideas, and has them in python and java. The python section is a little lacking, but there are a lot of recursive problems given in java, which alone should be a huge help, as writing the code isn't really my problem, but rather, just being too inexperienced with recursive problems. (For the record, I am that one person who will try to use ridiculous long and complicated nested loops just to try to avoid recursion. It only works sometimes)