Sunday, 29 March 2015

SLOG: Week 11

Well this has been a rough long journey but I finally made it!
Looking back, I learned many new things such as object oriented programming, abstract data types, and probably most important of all, recursion. I still remember when recursion was a great challenge for me and every recursive function I wrote took me hours upon hours to complete. Now,my understanding and ability have risen to a level in which I could complete option B of the third assignment alone within a couple of hours.
I really wish I had more of a chance to apply the concept of queues and stacks since the main thing we focused on was trees. However, I'm going to try my best to incorporate it in any summer projects I choose to work on.
In the end, I found this course to be somewhat challenging but definitely manageable and if I had managed my time better and put some more effort in this course, I would certainly have gotten 100%.

On another note, this week we talked about the runtime of the quick sort algorithm. Quick sort has a runtime of nlog(n) (log base 2).

This comes from the fact that:
Each time you call quick sort to split the list, there is a linear running time: n
Also you split the list in half each time and the number of times you can split it in half is equal to: log(n) (log base 2)

Thus the number of times you split multiplied by the number of times you can split that in half is: nlog(n)

The worst case however is if the list is sorted in decreasing or increasing order. When this happens quick sort cannot fully use its sorting potential.

Also, I really enjoyed reading Nana's blog post on binary search trees: https://nanalelfecsc148slog.wordpress.com/

Here, she discusses the optimal height for a tree. This case is when the height is at its minimum, in which case the runtime will be most efficient. This gives the result of a tree with a height of log(n) where n is the number of nodes. I found this particular detail to be very interesting and I feel like it would be very useful in the future when making any program with a tree run faster.

No comments:

Post a Comment