Sunday, March 30, 2014

Week 11: Penultimate Sorting Extravaganza

Let's take a trip down sorting lane, shall we?

This week, we learned about the different types of sorting methods we can use in Python (and other computer science languages) and why some of them should never be used *coughbubblesortcough.* It was actually quite interesting to go in-depth and see exactly how some of the sorting methods worked. And now, I'll basically regurgitate that info but also provide cool gifs (or not, they don't seem to work)! Yay.

Bubble Sort

Oh boy, here we go.  Bubble sort goes through the entire list and always places the largest item at the end of the list, causing it to have a worst-case runtime of O(n^2) which is not good. While there are some ways it could be faster, such as having to check only once if the list is sorted, seeing the times tower over the other ones reminded me that if I have to, not to use bubble sort.

Insertion Sort

I personally like insertion sort, though I can see why some people don't really like it. It just accumulates a list as it goes along, plopping the end item where it needs to be. Simple! It's usually better to use insertion sort when the list is nearly sorted since there's little overhead.

Selection Sort

Selection sort should be used around the same number of times as bubble - close to zero. It is just sloooooooooooow. It goes through the entire list multiple times and builds it from the smallest up. Please don't use it.

Shell Sort

Based on insertion sort. Very good for smaller nearly sorted lists. A+.

Merge Sort

Ah yes, merge sort. This method splits the list to be sorted into a bajillion pieces, sorts those, then smushes them together bit by bit and sorts them again. Pretty cool, to be honest.

Built-In Sort

The last sort method I'll mention. Please use this one. It's so so fast and absolutely destroys the other methods in tests. It's actually a hybrid method based on insertion sort and method sort so it's pretty much magic.

All in all, it was quite fascinating to see how the timing of these methods went up as list sizes increase, through charts and other methods, and also to perform Big-O analysis on them. Hopefully I'll be able to delve into them more in the future.

Sunday, March 23, 2014

Week 10: The Home Stretch

Oh boy, the last two weeks of class are finally here. We're really coming close to the end now. All in all, these week was pretty anti-climactic. Well, aside from my absolute insanity delving from trying to make assignment 2 work (spoilers: it didn't). I wrote some code as best as I could that would make some regexes work and some regexes ....not work, let's just leave it at that.

Lab was, in a nutshell, very interesting, kind of confusing, but in no way unexpected. It combined everything that we were working toward in the other labs (BSTNodes and Linked Lists) and smushed them into one neat package. Figuring out how to traverse these insane data structures was quite the feat, but in the end it all worked out. Although, I found myself staring at this diagram for what seemed like quite a long time:

In lecture, we discussed what might possible be the bane of my and many a computer science student's existence: Big-O analysis. Going through this in 165 is enough. Two courses? You've got to be kidding me. Thankfully, this side of it is more short analysis than writing out proofs dozens of lines long.

Until next time, where I talk to you alllllllll about sorting methods.

Sunday, March 16, 2014

Week 9: Assignment Two Part Two: Electric Boogaloo

Here we go, the home stretch of the course. It really feels weird to be almost done so quickly, but maybe that's just because I still haven't adapted to the shorter amount of time University is to High School, even after two years.

As usual, lab this week was quite interesting. I really do enjoy the labs, seeing as you are able to get immediate feedback on your work and the learning process is quite easy. This lab dealt with Binary Search Trees, which took me a while to understand since I'm very unobservant and didn't realize the mechanics of how they worked. Aside from that, the labs are probably my most consistent source of full marks for this course *nervous laughter*.

I haven't really begun to look at assignment two part two so far yet, but judging from what I've seen on piazza it's gonna be quite a doozy. Here's hoping that it gets done in time. All I'll need is a couple sleepless nights, monster energy drinks, and some adderall. Just kidding. Please don't do drugs.

Until next week.

Sunday, March 9, 2014

Week 8: Assignment #2 and other cool things

Leave it to me to procrastinate the entirety of assignment 2's first part until... 12 hours before due date. How do I keep doing that?

Thankfully, this part of the assignment was actually quite simple once you got down to figuring out how the inheritance structure worked. It also borrowed quite a few elements from the already-implemented Tree class shown in lectures which made the process even simpler.

Now, we wait for the second part.

The good thing about this course is that even if I'm completely flubbing the midterms, I'm still learning and building upon my knowledge. Recursion is still an iffy topic for me, but I'm still hella impressed with myself for amassing so much knowledge of programming since I didn't even know what a for loop was a few months ago.

Nonetheless, I'm ready to take whatever this course (and PoST) throws at me next.

Saturday, March 1, 2014

Week 7: Recursion

Hoo boy, recursion. What a super fun topic.

In all honesty, this is one of the most frustrating parts of programming, especially for a newbie like me. Figuring out how to recursively call your function and implement it has given me major headaches. Fortunately, I'm getting better at it and am able to understand it (at least a bit).

We just used it in our lab, where we also learned about the LinkedList class, something that works a bit like the Tree class, but only links to one other element. We had to implement prepend, decapitate, and insertion methods that used recursion to trace the lists and perform the function on them - letting us treat LinkedLists like the normal list type found in python.

I know that this is really just the start of my ~*~*~wondrous~*~*~ journey with recursion, and it definitely won't be the last I see of it.

Now, to get started on A2...

Friday, February 14, 2014

Weeks 5-6: [Programming Intensifies]

This is where the course material really ramps up in difficulty. While the first few weeks were pretty straightforward, weeks 5 and 6 introduced us to the subject of recursion, which requires quite a bit of thinking to implement correctly.

These were also the weeks where we had to complete our first assignment of the course, a project based on the "Towers of Hanoi" game: Finding out the least number of moves you could move one set of discs from one peg to another.

However, we also had to implement the 4-peg solution, also known as "The Reve's Problem." This was very challenging for me. So challenging, in fact, that I wasn't really able to complete it. Something about the outline was making me draw complete blanks that I ended up staring at my screen for hours on end. Fortunately, I did complete enough of the material to earn around a 70% on the assignment.

In hindsight, I really should have partnered up with someone or not started so late, or gone to the one office our I was able to go (work cuts into my schedule a lot).

Since assignment two has now been posted, you can bet that I'll be doing everything I possibly can to get it as finished as possible.

Sunday, February 9, 2014

Weeks 1-4 Catchup

I figured I might start on this now.

To all of you students and TA's alike who have been absolutely dying since they haven't been able to see the wonderful content I haven't posted yet, here's a huge chunk of info to make up for the posts I haven't been able to do. I, personally, am in quite an interesting position to be taking computer science. I'm actually a second-year student at UofT. However, after trying (and failing) to get into Rotman Commerce last year, I decided to attempt switching to Computer Science as it's something I've always wanted to explore, but never had the chance to get into.

I've always been into computers and various electronics, even designing a few custom builds (one of which has sat back in Ottawa for the past few years). However, I never took programming in High School, so I thought I might start. Surprisingly, CSC108 last semester was not too difficult, and I found the concepts easy to grasp and the teaching style very effective. I wish I could say the same about CSC148/165, but maybe I just haven't been studying as much as I should.

From what I've done in the courses so far, I quite enjoy it. All the technical aspects of programming and testing whether your code is right fall right into how I like to do work. It's almost like learning another language, too. You have to learn all the terms and syntax for all the pieces to fit together perfectly.

Object-oriented programming is a bit different from the style we used in 108, but it is a welcome change. It allows me to delve deeper into problems and focus on them on a bigger scale - I feel like I understand what I'm trying to code more. The style guidelines also took some time to get used to, but I feel like they clean up the code considerably.