Saturday, 5 April 2014

Week 12

I know I don't have a post for week 11, but I pretty much did week 10 and 11 in a single post. This was the last week of class of CSC148 and pretty much an entrance into the summer of 2014. Learned some new tricks while learned to use old tricks better this time around.

I think my favourite topic in this course was recursion and its related labs. It was really fun finding a really tiny solution to problems that can be solved recursively. The only recursive problem I didn't enjoy was from assignment 1, but I recently saw a post from another student that helped me understand a lot better at what I was doing wrong with it.

I really liked Dan's teaching style, it was casual, but he had his serious moments too. I wouldn't mind him teaching again for a second or third year computer science course. I also read, commented and shared some of the other student's slogs through my own (on my Google+ page), they had some great ideas for different kinds of approaches to difficult problems in this course.

Was a good year overall, looking forward to seeing people from CSC148 in CSC207 next year.

Thursday, 27 March 2014

Week 10

This week we learned about sorting algorithms. There are a lot of sorting algorithms out there and we learned a few of them like bubble sort, quick sort, merge sort and insertion sort. My favourite one is Bubble sort because it sounds like I'm saying "Bulbasaur" and it is probably one of the slowest sorting algorithms for extremely large sets of data.

I remember implementing and learning about sorting algorithms in grade 11 programming class back in high school, that was really fun. There, we actually did an assignment where we searched up some different kinds of sorting algorithms that weren't as cliche to learn in a CS class (Yeah, I'm talking about CSC148). On the test there, one of the questions asked to implement one of the sorting methods we did on the assignment and I remember writing code for "Gnome Sort", I don't even remember implementing it correctly at all.

Any ways, the great thing about the sorting algorithms that we did in the CSC148 lectures that I already knew about is that there are countless ways to implement them in any programming language. The simpler the implementation, the more efficient the sorting algorithm performs, right? WRONG! Each sorting algorithm has an efficiency that is already been determined based on the worst case scenario.

I did OK on the test, didn't try very hard at all. Probably should have studied more, but I was busy playing Alliance of Valiant Arms. Didn't bother going to the lab, because I had some medical stuff to do, not that it would matter to anyone. Just waiting for the exam now so that this class can end.

Thursday, 20 March 2014

Week 9

This week we learned about complexity. We were introduced to Big-Oh notation which help us understand the efficiency of our code based on many how steps the code takes. The lecture started with working on creating a program that finds all of the words that are anagrams of a given word. First thought was to use the permutation approach, which was not a very good solution since the amount of work we estimated was a lot depending on the length of the word and checking if all of the generated permutations are real words or not.

The second method to solving the anagram code was something Dan called "Signature approach". Basically, you take the argument word and re-arrange its letters in alphabetical order and then that becomes the argument's "signature". We can then generate a list of anagrams of the argument by checking if their signature is the same as our initial one and this proved to be a better solution.

I am not very comfortable with determining time effficiency yet, but I will be practicing it this weekend so I should be ready for next week. I think next week's lab will be based on determining time efficiency of given code and finding most efficient solutions for given functions.

Sunday, 16 March 2014

Week 8

Binary Search Trees was the topic of week 8. BSTs are like an extended version of a basic binary tree, except you've got your insert() and find() method as well some specially designed classes called nodes with their own unique methods as well.

Nodes are the thing inside the BST that contain the object you want. A BST has left and right spots and by default they are None OR you can define a custom version of BST Node called BSTNoneNode or something similar to represent a Node that is null. By creating this empty Node class, you can avoid getting errors when searching through BSTs, because you won't be accessing a Node that doesn't exist.

BSTs use recursion to find items as well as calculate their maximum height. The lab we did, we were given 4 classes and we implemented a method count_less(n) that counts number of items in BST less than n and returns that value.

Essentially, all 4 of the py files, we used recursion to create the count_less() method. I ended up creating one-liner count_less() methods and they were pretty efficient I'd say. My initial idea was to use ternary expressions to count items less than n.

For example, I don't know if a lot of people know this or not in our class, but I can convert boolean expressions to an integer by type casting them:

int(True) == 1 # This would return True because if you convert True to an integer, it becomes 1

Along with the above, ternary expressions proved most useful, because essentially, what the count_less() method returns is 1 or 0 along with a recursive call count_less() on both of its nodes (if they exist).

Thursday, 13 March 2014

Week 7

This week we learned about Linked Lists. A Linked List is kind of like a list of lists, except in a Linked List, you've got the item (can be any object) and the next item (can be None or another Linked List). This week's lab was learning to re-create Queue class using the Linked List instead of python's built-in list class.

The goal in this lab was to see how implementing Linked Lists for Queue class improved efficiency. When we implemented the Queue class using a basic list, the dequeue() method was what really made the whole class perform slow.

A lot of people didn't finish the lab, so next week's lab will be the same thing (try to finish the enqueue() and dequeue() methods to receive the mark).

Linked Lists are a pretty easy concept and are easy to re-create. You just have to understand why they are called "Linked" Lists.

Sunday, 2 March 2014

Week 6

This week we learned about Binary Trees and just Trees in general. Even though this data structure is called a Tree, it has nothing to do with a real tree, except some of its characteristics that match a real tree. Of course, you don't need to know about a real tree to understand what the Tree's characteristics mean.

A Tree has a root, branches and leaves. Leaves are the outermost objects that have no children. Roots are the parents of children and branches are what connects parents and children. Roots start out empty and you can fill the left and right sides of it and then do the same for those.

You can trace trees using recursion; meaning you can calculate its height or find a specific element just by going through the tree.

We also did a list-of-lists implementation of Binary Tree, which was moderately easy enough to follow and understand. I was even able to re-write the implementation at home a few hours later without having to look at class notes at all.

The test went well and I am happy with my mark, considering I was quite ill and barely had enough strength to make it to class without vomiting brutally.

Sunday, 16 February 2014

Week 5

We worked on more recursion, except a bit more "advanced" stuff. I'm getting the hang of recursion again, been almost a full year since I did python. The lab was about "Python idioms", which is basically some really compact code that does a lot of stuff related to for-loops, except it is really short. In that lab, we got to convert that awesome python-idiom code into a really long (in some cases, nested) for-loop or while-loop mess and do the exact same procedure as executed by the python-idiom script. The functions we got to implement did pretty basic tasks such as dot product. The whole thing was a really great set of exercises and I think everyone enjoyed doing this lab.

Besides the lab, we learned something called "binary search" and I'm pretty sure I know what is going to come up during the next week related to "search". Lectures seemed short; I guess time flies when you're in a lecture that involves programming. Next week is going to be complex, I can already tell.

Sunday, 9 February 2014

Week 4

This week we learned about recursion. Basically recursion is a way of solving problems by repeating a set of operations using results that were returned by the same function. Recursion usually has a base case and a condition that checks whether or not to repeat the function. Induction and recursion are awfully similar, I remember doing induction in MAT102 last year and it was one of the best things we learned. Recursion is the same deal as induction, so when you have a problem that can be solved with recursion, you can simplify the solution greatly and you end up with something that is easy to understand and manage, and if needed, modification is easy too.

This week's lab was on recursion and we started off with tracing some basic recursion functions written in Python. Tracing is a great way to see step-by-step how a recursive function (or pretty much any function) will work and you can even find errors that are hard to see by looking at code. The pen and pencil method of tracing really works, I was originally convinced that it was pointless, but I understand why it works so well now.

I am going to use these new techniques in my upcoming projects and see what the team comes up with next.

CSC148 is turning out to be full of impeccable knowledge.

Thursday, 30 January 2014

Week #3

In week 3, we learned about Exceptions; what they are and how to use them. I have done Java previously for 3 years, so I know about exceptions, but they work a bit differently in Python. In Java, they are try-catch, but in Python they are try-except, which I find is a bit strange. Usually when someone throws an object, the other person would try to catch it, but in this case, I guess they would "except" it, ha ha.

Any ways, the lab we did this week was also pretty straight forward but fun to do. I finished the lab successfully, which made the day even better. Lectures are also getting more interesting as we are progressing deeper into Python. I mentioned it in the discussion forum of CSC148, but I'll say it again here; I found the "" to be quite funny because it reminds of me wanting to be a dentist and a programmer at the same time.

The lectures are not full every time, albeit IB 110 IS a big room. I am wondering if there aren't a lot of students in class or maybe they don't come to class anymore, but the size of the class really decreased lately, a lot of free seats.

Looking forward to seeing what we will be doing in class next week. Hope everyone has a good weekend.

Tuesday, 21 January 2014

Week #2 of CSC148

Week #2 of CSC148, we went through lectures on stacks and queues. What I found interesting about these two was the efficiency of both is different. Stacks are faster than Queues, assuming that the Queue class's dequeue() method is not optimized, while the Stack class is very easy to optimize.

Besides that, there was a question we did in class about finding the size of a stack. A lot of people found different ways of doing the problem and everyone learned that there were definitely a lot of efficient ways and a lot of not-so-efficient ways. It was a pretty good practice problem for testing what the best and fastest way is of solving a problem.

Last thing we covered in a hurry was the balanced parentheses problem. This problem was a good one as well. It tested our String manipulation skills. I was hoping we had more time to discuss the problem in lecture, because I wanted to see what other people came up with. I'm sure there were a lot of ways of doing it.

Overall, week #2 was excellent and enjoyable. Looking forward to next week's lectures.

Week #1 of CSC148

As of today at 11 AM, the first week of CSC148 is over. This week was mostly review from what was previously learnt in CSC108. Of course for me, it was a review from two years ago, since I took CSC108 in 2012.

The first exercise was posted on the course website and I have already finished it. I haven't programmed in Python for a while, but they were review, so it wasn't too bad.

Still waiting for the MarkUs link to be up so I can submit my SLOG.txt as well as my exercise py files. One thing I like about all CSC courses is the discussion board. It's a really useful thing and a lot of people who are either too shy to ask a TA or instructor directly or are in no position to go to a TA or instructor's office(s) can just post there and get a quick response from other classmates.

So overall, this week has been pretty good and I am interested to see what we will be doing in CSC148 next week.