Wednesday, 30 March 2016

Runtimes

The last lab performed really caught my attention, especially in conjunction with the content of CSC165. Comparing different search algorithms, and plotting the difference made a big difference to my practical understanding of what it means to have a good or terrible algorithm. Working with very large sets of data is becoming increasingly important in many fields, and we don't have years to wait around for bubble sort to get us answers! Seeing the obvious differences in runtime as a result of increasing list size by a factor of 10 like in lecture was particularly impressive, especially when you're used to seeing google display things like "About 1,320,000,000 results (0.42 seconds)"

Queues in real life!

I'm very excited to have a concrete example of how this course has changed the way I think to be more like a computer scientist. In one of my extracurricular clubs, we have been experimenting with a new system to prioritize who speaks when during meetings, and recently discussed creating a position of "speaker" (someone who helps control the flow of discussion and regulates speaking times). The way this system works is if you have a direct response to what is currently being deliberated, you hold up one finger, and if your point is related but slightly off topic or will change the direction of the conversation, you hold up two.

I was immediately enthused with this system being introduced because I recognized it right away as a priority queue, only more complex than FIFO or LIFO. The idea of programming something that could act as the "speaker" for this club was compelling and I will definitely consider this as a project for future.

List[i] for i in comprehension

I have quite a bit of trouble with list comprehension. Usually, I can get the hang of it eventually. Eventually.

My brain has a much greater penchant for classic for loops. List comprehension can get a little sneaky in the following ways:

1) "for"s in all the wrong places - getting a grip on which parenthesizes a for should be within and which ones it should sit outside of is a little tricky at first

2) sometimes you shouldn't use them at all - you have to know what you have, and what you want. List comprehension only really works when you're going from an iterable, to generating a list

3) surprise generator functions! - this is a problem I keep running into. especially when trying to juggle recursion and list comprehension at the same time. If the recursive pieces aren't all perfect, a generator function is sometimes passed into somewhere it shouldn't be. I'm not always sure what that means, let alone how to fix it.

All in all though, elegance and increased efficiency make it worthwhile to figure out ways around these tricky bits, and use list comprehensions.

Painting with turtles

In class, we saw a function that created a fractal like picture, using turtles of different colours. It was quite beautiful to watch it go, and emphasized the exponential difference that changing the starting "base" size of something like this can have. Starting at 3, the entire process finishes very quickly, whereas with a base number like 5, it takes significantly longer.


Binary Trees

The binary tree is a really nice way to store sorted lists, and makes me think in a different way about search efficiency. I can see the use for level order visit, versus pre-order for example, but I have difficulty thinking of situations where one of pre-order or post-order or in-order visits might be preferable over another. I thought it was interesting to also see the tree that held operators in its nodes for arithmetic operations of its leaves. I would like to investigate expanding this for use with other mathematical manipulations.

Wednesday, 2 March 2016

Recursion

I was first introduced to recursion not long before CSC148, with a very simple example of how it could be used in a factorial function. I greatly admired the elegance of being able to call a function within itself. The most difficult part of tracing - but also the most interesting - is that the base case is not called until the very end; when you have dug as deep into the call as you can go. For n! this looks like n * (n-1) repeatedly, until n = 1.

Now, having taken a look at recursion in several other examples, I've found that it can be much more complex. Not only can functions be defined recursively, but this can also be applied to class methods. Recursion can be very helpful for tasks such as learning about tree-like data structures, where the values held at nodes can't be indexed. In class, we implemented recursive functions for things like finding the height of a tree, or how many leaves it had.

Tracing an implementation, as a result is significantly more difficult. However, because of the nature of the data structures that I've encountered so far, visualizing recursion is relatively easy. I'm sure I will be drawing plenty of pictures in order to handle upcoming labs and assignments.

Thursday, 4 February 2016

SLOG update

Recently got more practice creating abstract classes; I have to remember to double check when there's a list-like attribute, so as to not forget to use it when trying to use and test implemented functions for the class. For example, it took me much too many tries to realize queue.add() should have been queue.line.add(), in lab03.

I'm interested in learning more about when linked lists are preferable to store information, and I am trying to think of cases when one might need to split a linked list into multiple others. If this would ever be useful...

Python - and coding in general for that matter - seems to be all about spending time and effort in order to learn how to be as lazy as possible

Tuesday, 26 January 2016

CSC148 - introduction to slogging

The point of a courSe bLOG is to enhance the in-course experience I have as a student in CSC148. The process of reviewing what has been presented during lecture in my own words, as well as being able to comment on where I've made errors in my work is meant to aid my understanding of the content, and help me 'rubber duck'.

Working in a public space makes me nervous in that I have to record all the silly mistakes I make along the way, but I am excited to be able to look back and see my development as a python user.

Beep boop