2013년 12월 1일 일요일

Sorting algorithms

When we are working with a list or a dictionary, they are not usually in order. Thus, people came up with certain measures to cope with the random order so that the list becomes easier to use. Of all the famous sorting algorithms, I am going to discuss about the selection sort, quick sort, and merge sort.

Firstly, selection sort is a sorting algorithm that finds the minimum value from the remaining values and moves it to the front. As a result, swapping the values may occur very frequently in selection sort in some cases. For example, if the list is in a reversed order, more swaps will occur than when the list is in a sorted order as the program has to scan the entire list to find the smallest values that are located at the rear part of the list.

Then there is a quick sort which uses a certain value as a pivot and places the smaller values before the pivot and the bigger values after the pivot. Quick sort's efficiency depends on where the pivot is located. If the pivot is the first element of the list, then quick sort will be faster in the randomly ordered list than the sorted or reversed list. This happens because the pivot will have to change every time when there is no smaller item than the pivot.

Finally, merge sort merges the sorted lists in order. That is why merge sort is the fastest in the nearly-sorted list and the reversed list. Merge sort may be deemed similar with the quick sort as divide and conquer is the same strategy they both use. When quick sort also divides the full list into two parts and work from there, merge sort divides the full list into half so that the comparison among the two parts are optimized in terms of efficiency. Quick sort's pivot moves at one element by one while merge sort's pivot moves by half of the entire list.

However, the fastest sorting method is the built-in as the list.sort method uses different sorting algorithms based on the size of the list. Alike Timsort uses merge sort and insertion sort, built-in sort is a hybrid sorting algorithm. In other words, the efficiency of different sorting algorithms differs from every case. Usually, quick sort is the fastest in almost every cases only if it is randomly ordered. Selection sort is the slowest because it visits len method too many times if the size of the list is too big.

2013년 11월 26일 화요일

Changes made to Computer Science Minor Program..

I just received an email from the Computer Science Program saying that the minor programs will require the students to have 75% in CSC148H1..
I am confident in acquiring over 75% in CSC165, but now I am not so sure if I will be able to acquire the mark of 75%.
It even said that satisfying the mark will not guarantee the admission to it.
Applying after second or third year might work for me if I achieve above 75% from CSC207H1 and CSC236H1.
I think the work is getting harder and harder as the years pass.
The major program requires average marks of 67% from CSC148H1 and CSC165H1, or 70% from CSC207H1 and CSC236H1 after second year.
I understand why the Computer Science program is limiting the admission of Computer Science Minor students..
But I think it's quite unfair for the students whose only option to study Computer Science is to do the minor.
But again! If I get the mark above 75%, the case is solved!
Haha, so! let's study harder to get that mark!! :'(

P.S. 75% is still B, 3.0!

2013년 11월 22일 금요일

Skipped last week's entry T_T

Whoa, there was a 2nd term test last week.
I guess I was so panicked out that I forgot about this blog (lol excuses)
I lacked of time, and I honestly thought that it was impossible to solve them all in an hour...
But it looks like it was possible after all, it's just I didn't know how to make the code concisely yet.
I thought I was actually doing okay understanding the lecture materials, but I realized that I had to try harder than that.
As for now, final is the only chance I can make it up for.
In the lectures this week, I learned the reduce method, which I thought it was cool stuff.
The structure is hard to understand when you see it for the first time, as in coming up with how to use it without any explanations. (at least for me)
Then I went to the lab... I saw all the codes that are hard to understand and was difficult to come up with, haha.
After looking at the code for over two hours, I sort of get what those codes do.
However, now I lost my confidence again..

I still hope that I can do well in the final after doubling up my effort!

So for now! Enjoy your weekends for now! XD

2013년 11월 11일 월요일

Happy long weekend everybody!

Although the weekend has already been officially passed, the weekend hasn't ended yet!
Happy Remembrance day, and thank you for the opportunities you have made in North America.

After this long weekend is over, there will be my second term test for CSC148.
I need to prepare for it, and luckily, from the last lab, I feel like I have gained some understanding on the Tree node and the Linked List node.

Frankly speaking, I wasn't able to finish it by myself.. and thank you my TA for walking through the code!
I had to understand the difference in the structure of the two different nodes.
Without thinking it, I just treated the Linked List node like a Tree Node. (Obviously, the result wasn't what I wanted)

I enjoy the tutorial more than the lectures..to be honest, haha.
When I'm in the lectures, I understand everything and I know that I know those stuffs professor delivers..but then, when I start to code all by myself, nothing turns out to be what I expected.
So I am really thankful for the lab times!
and.. the reason I brought this up is.. that there are only two labs left from now..
What a shame T_T

But hey, enjoy the rest of the long weekend! and good luck to everyone who has the CSC148 term test!

2013년 11월 3일 일요일

After exercise 6

Okay, so after the assignment and the exercise #6..
I think I finally start to understand something at least.

First of all, Binary Search Tree seems like a better structure than just the Binary Tree.
Obviously, that must be the reason there is a separate name for Binary Search Tree.
So what is this Binary Search Tree?
The items in tree is in order.
By that means, the smaller items are located in the left children of a root, and the larger items are located in the right children.
Of course, the children have the same behavior of having smaller items in left branch, else the right branch.
I like this structure because unlike the normal Binary Tree has its values randomly everywhere, Binary Search Tree is more neat when you see it.

However, I still don't understand the use of the Tree nodes.
Yes, the Tree nodes represent the hierarchical data and it makes the data more easily searchable.
But what is the practical use of it?
Maybe I don't know this quite well because I am still in the learning stage..
Because the Wikipedia gave me an answer of a "workflow for compositing digital images for visual effects" as one of the Tree nodes' common uses.
..Just to be honest, I don't really want to know about it, haha.

P.S. Oh wow, I didn't know BST also applied to strings as well!
       Cool stuff, lol


2013년 10월 26일 토요일

Nodes, Tree Nodes, Binary Nodes, N.O.D.E.S, Assignment #2

Looking at the SLOG topics suggested,  something new I learned from this week's class is Nodes.
But then, what's something I enjoyed in this week's class? Learning to use BTNode class reducing the effort to repeating the lists, probably.
As I said in the previous entry.. (or maybe not :P) the nodes are a way to represent linked lists, at least I think it seems like it to me. Thus, Nodes may entail recursions with a high probability in the codes.
Now, what is something that challenged or frustrated me this week? I don't get it O_o I don't get it, I don't get it!
Okay, maybe I'm just not so familiar with the structure yet.. I really really need to go to the office hours a lo from now on.
Even when I was working on the assignment, it took me a long time to figure out what the assignment actually meant! (although professor already indicated that it will require some time to understand the contents first)
I hope this assignment can be done perfectly..
Last time, I was so frustrated because I was the only one working on the assignment and even worse, the starter codes I had had some differences from the others'.
At least now I received some other students' assignment #1 to refer to what I have missed after the assignment due date, I understand that it wasn't something that I could do by myself.
So I decided to visit the office hour from this week, maybe the help centers as well.
Cross me fingers so that I can finish this assignment with my partner thoroughly!

2013년 10월 19일 토요일

Midterms!!

After taking the midterm for CSC148....
I felt so miserable for making such a stupid mistake!
I copied down the method implementation and executed it after the midterm..and...
I knew the min() function was supposed to return the tuple with the smallest number in it, starting from the first value in the tuple.. (well, actually I was half sure..haha)
I didn't have to look for a certain logic or a rule in the outputs! (thinking too many steps ahead always had been my problem!)

But guess what!
I thought Nodes will be covered in the midterm, but they weren't in the midterm!
I still don't understand why Nodes are so important, but they sure are some cool structures as many values can be inside one item, although we only learn binary node in CSC148..
But thanks to that, we don't have to go through so many None values inside the Nodes, they are truly annoying to type all in..

However, after taking this course, I hope I get a better understanding in the computer science, not only the Python. (To be honest, I think I am starting to understand quite a lot already! :D)

P.S. It was shocking that we weren't provided with the built-in codes.. I should have realized it when the professor said a sheet of notes will be allowed as an aid.. but the codes are just so vast!