Wednesday 2 April 2014

Sorting and Efficiency

The process of putting the items of a list in order is a straight-forwards enough task, but with enough required steps that it's pretty much the ideal task for an introduction to algorithm analysis with the multiple different possible implementations for each algorithm. We studied, edited and compared selection, insertion, bubble, quick, merge, count and  methods throughout the last several weeks of course material. Many of the algorithms had a worst case scenario in which the algorithm was significantly more inefficient than it was expected to be, generally when the list was either sorted or reverse sorted. This can be generally remedied by randomly rearranging the list beforehand. In the case of small lists were the worst case has a higher chance of appearing randomly the small list size should be processed in a fraction of a second regardless. For lists with hundreds or thousands of elements where the runtime really shows, the list randomly sorting into a significantly undesirable configuration is too unlikely to be problematic. Of course the scrambling itself would add a bit to the runtime, but oh well it all comes out in the wash.

Sorting methods that go over each element in succession generally have a sorting time of n^2 where n is the size of the list, as with each additional element it creates more possibilities for the relative position of all the other elements. Sorting methods that sort the elements between two or three large groups and in turn sorts those groups into smaller groups generally have a sorting time of  log(n), as loosely sorting the all the elements continuously will always be more efficient than picking and choosing between two individual elements.

Saturday 22 March 2014

Yet Another Update

So it's coming down to the final few assessments before finals. I started phoning things in during the middle of the course, but since most of my other courses don't have any more big assessments I can devote all my enthusiasm for learning and knowledge to getting ready for the second term test and hopefully finish strong. I already feel pretty good about the second assignment, and ended up submitting a version I felt was complete a day before the deadline, but in some ways how straight-forwards it felt to me (Just chopping up strings with exact specifications as to what you'll find and feeding them into a recursive function? sign me up.) compared to the first assignment is starting the mind games. As in, "If I thought I did a good job, it must be TERRIBLE."

There's been some algorithm analysis material that I don't feel confident with, but I guess I better get comfortable with it because it's probably going to be on two different exams for me. At least after the midterm on Wednesday I'll have a few weeks to get over my distaste for accepting academic help and be able thoroughly acquaint myself  to the big-O. After that the only assessment I really have is the final exercise for this course, but what could possibly go wrong?

Sunday 16 March 2014

Another General Update

I've definitely been neglecting this blog, especially between having a duedate every weekday the past several weeks, fatal computer hardware failures, and general physical/emotional fatigue from hurtling towards the end of term, so I guess it's time for another update.

The last handful of programs I've written for the course I've been happy with how intuitvely I've found the answer, and I would consider myself very comfortable with recursion at this point when I was guessing a lot of figures and syntax at the beginning of the course for recursion problems. Though at first I didn't like using nested lists to represent trees, I really enjoyed assignment 2 part 1 and exercise 3. Exercise 3a has been my favourite program in the entire course because it felt like some kind of traditional logic puzzle where there bare minimum to find the final solution (the proper tree) was given and the students' job is to use the information and how it interrelates to find an answer.

Despite having to hand over my personal computer for repairs, I managed to submit an updated version of e3 that I'm fairly confident in. The remarks for Assignment 1 are going on, but I figure just trying to put my best into Assignment 2 pt2 than go through that old mess and see what can be salvaged and just save my mental and emotional energy for something upcoming.

Sunday 2 March 2014

Recursion

Recursion is a nifty little programming trick in which a function calls itself. Depending on the nature of the function, recursion can be used to streamline a variety of tasks, such as parsing and creating nested objects, creating several objects containing values relative to each other in some way, or splitting a large algorithm into several small, easily calculable  parts. It's an important element of writing efficient code, as the same set of instructions are read every time a function calls itself again. However, it's also sometimes difficult to trace and keep track of all the interacting elements, as with each iteration there is a new set of input values and a different return value. But hey, no one said it was easy being beautiful.

I found recursion in python very difficult at first, making mistakes like forgetting to put return statements where they were needed (Note to any student readers: never forget the return statements.), returning data as the wrong type, calling the function with the incorrect number of variables, ect. Staying away from the single-line, ultra-dense return statement functions helped with tracing the code, seeing it spaced out and organized in an order that made sense to me helped a lot in labs, and by the first term test I felt comfortable enough to answer the recursion question in a single line.
At least I think I did.
The test was first thing in the morning and I was really sick, so the whole thing's kinda a blur.
Pretty sure I did well, though.

Monday 10 February 2014

General Update

It's been a while since I made an entry, and I still have trouble thinking about what to say about the past two weeks. I entered the course a week late, but have had no problem keeping up with the material. I've completed all assignments just fine, only using the extra help resources once for an overlooked capitalization error. Other work and more pressing due dates have been keeping a lot of this course at the back of my mind, but I'm confident enough in my programming skills to get what needs to be done finished. I'm starting the first assignment today after having two very busy weeks in other courses/life in general where it got put on the back burner, but I have no concerns for it. I guess the short of it is that I'm getting the work done and feel nothing profound enough to entitle a blog entry, which is good academically for me, but bad for this assignment.

Oh well.

Thursday 23 January 2014

Object-Oriented Programming

Object-oriented programming is all about making large, complex programs out of modular self-contained objects that contain both data and operations. I am familiar with the concept and was taught to work in Java following the model, but I'm kinda awful at it because I will copy and paste dozens of lines of code over again in one single mother-function when no one is looking. Which is exactly what I did for a side-project I submitted earlier this evening that was created in a language that's meant for object-oriented practices. Whoops.

Looking back on the mess that was, I'm kinda thankful that there will be some encouragement towards object-oriented programming and similar kosher practices. Faced with an uneven ugly, minimally commented text tower that feels like it could break down at any wrong-placed modification or misused find+replace, I think some pretty, self-contained objects will be a welcome addition to my life.

PS: I'm sort of assuming that what's expected here is more personal ramblings than a concise regurgitation of the course material because the avenue for this assignment/semester-long-learning-quest is supposed to be a blog. As well as the fact that something clinical and generic that could easily be copied from another website can't be illuminating for either the writer or the reader. If not, the ramble about what a bad programmer I am submitted above is on the house.