Thursday, March 27, 2014

Sorting Algorithms and Big Oh Notation

These past weeks we've been learning the types of sorting algorithms and how they would perform as the input gets larger. While there were the ones I was already already familiar with in csc108, bubble, selection and insertion sort, a few new ones were introduced. The new sorts were 'Merge', 'Quick' and 'Tim' sorts. The merge sort algorithm consists of breaking down the input list down to one element lists and merging the  lists back into a new sorted list. The quick sort using a 'Divide and conquer' method, by picking a pivot, and using markers, splits the list into two, and then quick sort the two. Tim sort is the sort python uses, it's a hybrid sort of merge and insert.

All of these types of sorts have a best and worst case runtime, depending on the features of the input. For example, if the list was sorted already or if it was reverse order or if the list was sorted already. In class, we would also look at how the algorithm would behave when the input size changes; seeing how the runtime would grow. We called this Big-oh for simplicity's sake even though the. We would say an algorithm would be big-oh of 'something' which would mean the algorithm is growing 'something' for a particularly large input.

Other than that, I finished my second and last midterm of the class. I felt that I needed more time for the test. I think I could've finished it, if only I had a little more time.

-Tri Tran


Monday, March 3, 2014

Recursion

One of the recent topics I have learned was 'Recursion'. Recursion is basically a function calling on itself, creating a loop. To stop the recursion, we have a base case which is basically a condition to know when the loop to stop. In class, the lecturer is usually writing recursions in comprehensions, mainly list comprehensions, which I'm still trying to get a full grasp on. I think writing recursions in a body is more for me, just because I'm more experienced with it.

We've also learned about recursive structures. One being 'Trees', as my previous post has partially mentioned. Tree's being structures that resemble what the name suggests. They have nodes and paths, and the top primary node which is called the 'root', which is the first node of all pathways. All trees have a unique path leading to a certain node. Nodes with no 'child', or leading to another nodes can be called a 'leaf'.

How recursion is used in these structures is how we access them, there are three ways to access them called 'Traversals'. There are three traversals: Pre-order, In-order and Post-order traversals. Pre-order meaning going from root to left-subtree to right sub-tree. In-order going from left-subtree, root and to right-subtree. Finally post-order going from left-subtree, right-subtree and root. All of these traversals use recursion to work, checking if each node has subtrees or is just a leaf. That's a bit of what I learned of recursion and some ADT's that use recursion.


Tuesday, February 18, 2014

CSC148 First Assignment and lab

I'm currently on reading week, so freedom for a week. The first assignment due last week and unfortunately I could not finish it. I felt the assignment was a bit confusing and troublesome and the handout to be kind of obscure. For example, there would be methods already defined in the class, but did not show up in the class' docstring. The handout of the assignment was obscure-ish, in my opinion, which I am not going into detail. There was not much help available for the assignment except for the last few days before the due date. But then again, I'm going to be honest and say I procrastinated a bit and should've started the assignment when it was given out; maybe put in an effort to seek help, go to the lecturer's office hours.

Lectures are kind of straight, not really having trouble with the content.  Learning about trees, nodes and recursions. Nothing really confusing yet.

Marks for labs and exercises are coming out pretty slow. I still have not gotten my first lab mark, but I emailed the lecturer and got no reply. But, I guess I got other things to worry about such as the 2 tests coming after the break, one of them being for this class. I hope I do well in it, probably should get a jump on studying it.

Monday, January 20, 2014

Sub Classes and Exceptions, Kind of New Stuff

This week, I am learning about Super Classes(base classes) and Sub classes. A Base Class is a basically the original class, where as the Sub Class of the Base Class is the class with all of the original class' and then some other methods to make it more unique. So far, I think I get the material of making a sub class. So, no worries there.

We are also learning about raising exceptions and making them. At first, when the lecturer talked about raising exceptions and everyone should know it how to raise one, I was confused. But when he asked the class to raise their hands if they ever raised one, only a select few had raised their hands. This made me felt more at ease, I guess. He, then gave an example of the zero division error exception, which I could kind of recall from csc108(a beginner-beginner course to programming, one for students who have little-to-no experience in programming). I'd say that I'm not really confident with this material, especially when the lecturer asked us a question at which exception would the call be caught, or something along those lines. I'll probably go ask a TA at the help center to clear things up.

Other than that, the first exercise of the class was pretty simple. Although, the instructions were kind of confusing at first, I read it through carefully and finished the exercise. Also, the auto-tester for the exercise was helpful too and probably got me full marks for it.

-Tri Tran