Wednesday 2 April 2014

Slog 9: Sorting

     I think the efficiency that sorting algorithms hope to achieve is pretty interesting. A balance between space and time is chosen for each implementation. This chart highlights the advantages and drawbacks of many sorting algorithms well. While graphing the run times of various sorting algorithms in lab 10, python's built-in list.sort() (aka. timsort) took me by surprise. The other sorts had a variety of approaches yet all lost to timsort. The short 'merge sort and insertion sort combined' explanation from the lab didn't show me why it would be more efficient. After reading a little more about timsort it's become more apparent. In real world data, values will be partially sorted here and there. By splitting the list into easy-to-merge chunks and sorting them beforehand, timsort achieves the speed it does. 
    One of the earlier labs, lab 5, had my partner and I write a function 'pythagorean_triples'. That was my first introduction to program efficiency. Our program checked every single integer within the given range even though a majority of them could be filtered out from the start. Did it really have to check if 
5**2 + 5**2 = 5**2? I realised that writing a working function takes one level of understanding and making it efficient takes another. I will have to keep this thought in tandem while I write other definitions and not make any unnecessary comparisons or assignments in future code.

Sunday 23 March 2014

Slog 8: BST

     The labs seem to be getting progressively tougher each week and this week was no exception. I feel as though the distinction between a binary search TREE and a BSTNode were not demonstrated well through the tasks in the recent labs. My TA was pretty helpful though, giving hints to point us in the right direction but not spoiling the thought process.
     Something about A2 part B. Using a combination of is_regex and all_regex_permutations is horribly inefficient and perhaps when marks have been given and released I would like to see a more optimal solution and the algorithm behind it. I would be interested in how it works.

Sunday 16 March 2014

Slog 7: TreeList

     I especially enjoyed exercise 3 this week. I had pulled up images of random trees trying to think up a solution to the task but came up empty for a while. Changing my approach I brought up microsoft paint and started drawing. After taking a few steps back and clearing my mind and remembering the absolutely helpful hint from lecture I had my algorithm going. That was for part A; now part B was a whole other beast. I wrote more versions of sum_to_deepest than I can count on my fingers. I followed the handout and wrote a fully functional method to determine the level of the deepest leaf in a given tree. However I couldn't find a use for that while summing. What I ended up doing was altering that method, and while adding up the levels, also sum the values and compare them at each junction. In the end, returning the sum that followed the level count worked for me.

Sunday 9 March 2014

Slog 6: Regex

     Another week another assignment, this time with Regular Expressions. Reading through the handout, it was great seeing these trees and nested lists again. I definitely remember how to do them from working on them during the weekly labs. Although I felt comfortable with the abstract data type and general idea, I still fumbled with some syntax errors while inheriting and other small things. This is probably a sign that I need more practice not in theory but actually writing code. The second part of A2 with matching regexes has me worried because I'm still trying to understand the rules and what string representations of regexes are equal. While testing code for A2 part 1, as was with the lab, actually drawing out visualisations of the trees really helped me keep track of the grand scheme of things.

Sunday 2 March 2014

Slog 5: Test

     Week 7 marks the writing and return of the first term test of this course. During the test I kept second guessing myself for the tracing question but seeing my mark, I guess I ended up with the correct return value. The question using the function sum to delve into deeper levels of recursion was very tricky but I kept looking at the base case that returns a value of 1 and ended up with that as my solution. I have noticed myself that I have a much firmer grasp on recursion but with problems in efficiency. Writing efficient programs seems to take more imagination and cleverness that I can't really work on. Though I enjoy having my TA during the weekly labs criticize my runtime and give hints towards efficient code.

Monday 17 February 2014

Slog 4: Tour

    Last thursday marked the end of Anne Hoy's tour and it sure was a difficult one. Comparing handouts with my group member, we noticed subtle differences that affected the clarity of the assignment even though we downloaded from the CSC148 website directly. I will be sure to check for updated handouts on future assignments so I don't miss any information that may have been added. ConsoleController and TOAHModel were pretty straightforward but still took a considerable amount of time for bugfixes and small errors. As for the recursive Tour.py, I still don't feel as though I fully understand how it works (the very efficient method that is). Working with my group, I only partially understand the most efficient solution and will be looking over it again later to see if it gets clearer how it works.

Sunday 9 February 2014

Slog 3: Cheese

    Before the fourth lab, reading through the Assignment 1 handout deemed pretty intimidating. I'm glad to say that lab #4 was incredibly helpful in making me more comfortable with recursion and how it works. Starting with simple examples and tracing to writing base cases and recursive functions to search lists, I thought the lab was really well put together. I enjoyed learning about scopes in lecture because it feels very abstract, understanding how Python actually works "under the hood"? Assignment 1 due this week, I hope to finish it early.