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)