Friday, November 29, 2013

wNov25_2013 ~ New 'Reviews' and more sorts.

Hello everyone,

This week the lectures are kind of reviewing in the sense that it goes over things that I am using already but explicitly explains why and how. We talked about the assigned value of a name and that it references to the address of an object at a particular memory location. There are different scopes to the names: local, nonlocal, global, and built-in. There are variation and difference in accessing and using methods. There are the tracing of recursive functions. We also talked about the efficiency of function by using a Fibonacci function as an example to explain. Quick sort is also involved in assisting us understand the efficiency of a program and how to make it efficient. Nonetheless to say, I am well aware of these concepts and ideas from my java experience, but it is always nice to have a nice refreshment once in a while.


Next up, I am going to talk about three of the well-known sorts in programming: they are selection sort, merge sort, and quick sort.


For following is based on 2 assumptions: n is the length of the list to be sorted, and the lists are to be sorted in non-decreasing order.


Selection sort is of O(n2). Each time it traverses through the list to find the largest element and then put it in the proper position. The sort does the aforementioned traverses exactly n times in total, and each time stops before the proper location where the list is already sorted. It is the least efficient of the three sorts mentioned here.


Merge sort is of O(nlog2n). It uses the divide-and-conquer strategy. It recursively divides the list into two parts of same length or one part being one more than the other. Then when the process reaches a base case, which is a list of length one, it is returned to its previous call in the recursive steps where the two separated lists will be sorted (essentially deciding which one will be in front of the other) and then merged into one big list. This merging process goes on until the last merge where the entire original list will be merged and consequently sorted.


Quick sort is also of O(nlog2n). Similar to merge sort, quick sort also uses the divide-and-conquer strategy. Instead of dividing the list into two parts of (almost) the same length, this sort partitions the list into two parts depending on the pivot value. The pivot value can be chosen in various ways, for example, it can just be the first element in the list. Every element in the front partition is less or equal to the pivot and the second partitions consist of any element larger than the pivot with pivot not being in any of the partitions. This is done by initially looking at the first (denoted i) and last (denoted j) element of the list and swap when necessary. Specifically, if i > pivot > j, swap i and j; if i ≤ pivot > j, j = j-1; if i > pivot < j, i = i+1; if I ≤ pivot < j, i = i+1 and j = j+1. These ‘if’ statements are executed until i is bigger or equal to j. Then, quick sort is called on each of the two partitions, and since they are not put into separate lists, they do not need to be merged in the end since they are always together; only i and j are changing.


In theory and in practical data where the pivot is not chosen to be something of the extreme (the lowest or the highest value), it can pretty much outperform the merge sort since it does not use extra storage; however, if the aforementioned extreme case does occur, quick sort will be of its worst case of O(n2), which means merge sort is more stable than quick sort.



I sincerely thank you whoever read my blog. Although I do not know who you are (or if there even is any), I hope you will have a nice life with no regret and blah blah blah blah…. And yeah…So, good luck and have fun.



Thank you for reading,

pilpho

o(@ _ @~*)o

Friday, November 22, 2013

wNov18_2013 ~ Something new and something old

Hi again readers,

First thing first, I congratulate myself for getting quite a good mark on the test I did previous week. Yay!! :D :D :)

As for this week’s lesson, the lectures were about hidden attributes, equality, and reduce, which I have mostly known already from my previous java knowledge except reduce.

A funny thing about python’s hidden attributes are that it does not strictly enforce us to not be able to use private variable but rather just add an ‘_’ to tell us to please not use it. Nonetheless, making a variable private means we will need a getter and a setter to operate on it.
Equality is also straight forward as we just need to write what attribute to compare in __eq__ method.

Reduce is something that I haven’t learned about yet. Seems to me that it takes an iterable and ‘reduce’ it into a single value. So it is kind of like the method ‘sum’. I have not yet fully understand Reduce, so I will be looking into it a bit more.



Thank you for reading,
pilpho
o(@ _ @~*)o

Tuesday, November 19, 2013

wNov11_2013 ~ Test 2 Done

For this week, I wrote my test 2 on November 13, 2013. It is pretty easy overall except that I may have made a small mistake where I am supposed to write something like n.item rather than n.item.value. I hope my thoughts at the time of the writing is correct.

That is all for this week, nothing unusual. All good.

Thank you for reading,
pilpho
o(@ _ @~*)o

Friday, November 8, 2013

wNov4_2013 ~ Time to review for that test

Lectures were the usual before an assignment that is due; meaning we mostly talked about the assignment during the lecture. So it is clear enough that it posed no difficulty since me and my partner already finished the assignment – all with recursion (kind of fun too).  Oh...Yay! We also learned about the big-oh notation (well, more like review for me), which is a nice refreshment.

With regard to this week’s lab session, the tasks seemed pretty easy to the eye, but when it comes to the actual programming, there were some difficulties. And I am (kind of) shamed to say that one of the difficulties was caused by me not reading about all of the details for the first task, which caused me to code in a way that is not supposed to be. I got to say though I really did learn some interesting tricks in coding in this lab session. Nonetheless, I never got to do the second task (Meh, oh well...); however, though problems occurred, overall, I still think the tasks were straightforward.

In the end, I just hope I do not develop unnecessary lasting habits with regard to python that would hinder my coding with Java, aka. things that can be done in python but not in Java.

Oh and lastly, the next test is coming up on Wednesday, Nov 13!

“I got to study!!!” is what I always say to myself, but I ALMOST never studies...(cough due cough to procrastination...cough)

Ha. Good thing there is the fall break on next Monday and Tuesday.  (More time for studying and procrastination)



Thank you for reading,
pilpho
o(@ _ @~*)o

Friday, November 1, 2013

wOct28_2013 ~ Easy 2 weeks

Hi there, this is Pilpho here bringing you the second blog post of my “life”.

But first... Although it was yesterday, happy Halloween to you all – whoever is reading. It was a great holiday to see people dressing up in various exciting ways (Indeed exciting)! Well, I did not go trick or treat’ing  but rather stayed and worked on my assignment two, which me and my partner finally got most of the program done and is currently in the debugging phase (the annoying ‘e*’ cases is really getting on my nerve... maybe).

Anyway, time to backtrack to the days between my previous post and this one. What I am learning lately has been pretty straightforward since my previous knowledge combined with my SUPERB learning skill (haha :D) can slash through any obstacle like uhhhh, ripping tissue paper (right...). Alright, all jokes aside, these materials I am currently learning is pretty easy: linked lists, Big-Oh notation, and Binary Search Trees.

These last two weekly exercises have been pretty straightforward and helpful to my understanding and proficiency to recursion. Exercise 5 from wOct21 caused a little confusion to me in part b, probably because I didn’t get enough rest and so my head was not functioning properly, but apart from that, all is good. As for e6 from wOct28, which is this week, it was extremely extremely extremely easy (see how many ‘extremely’ are there?! I mean it). It’s not that I am extremely pro at programming, it is that the questions are just plain straightforward themselves (Hopefully I did not offend those who did not get it J).

In conclusion, for the past (about) two weeks, I have increased my skill in writing and understanding recursive functions, and finished the study materials with (mostly) ease.


Thank you for reading,
pilpho
o(@ _ @~*)o

Tuesday, October 15, 2013

wOct14_2013 ~ First One!

Hello you, hello me, hello all to my first blog on here. You can write me ‘pilpho’ or call me ‘Peel Full’, or whatever. :)
Computer Science (CS), my favourite field of study, is able to do many tasks. Yet because its function is so vast, I do not know what area(s) to pursue in the realm of CS. So presently, I am exploring anything related to CS to grasp the big picture (hopefully), and then find one that I am interested in to pursue.
NOTICE: Whatever I am saying in this blog are my thoughts on things. It is not necessary the truth, though if it is the truth, then great, everyone is happy.

My understanding of Object-Oriented Programming (OOP):
OOP is a type of programming structural design (according to Wikipedia, the other designs are “imperative”, “functional”, and “logic”). As one can see from the naming of this design, the programming is build around objects interacting with each other. Each object may contain data fields for storing data (e.g. string, integer, list of real numbers, list of objects, and more) and may also contain methods for manipulating data (e.g. find the minimum number from the list of numbers). This design approach is useful for computer scientists in many ways. It allows for neat coding structure as each object can represent some distinct part of a complex problem, and these objects come together to solve the big complex problem. This gives computer scientist a clear sense of what is what.

My understanding of Recursion:
Recursion, in general, is just the repetition of something identical (or just similar) over and over again.

In Computer Science, recursion is the process of using/calling the method (aka. The Recursive function) itself inside itself over and over again, which sound like it would create an infinite loop, but it can be designed with conditions to exit the infinite loop, such as giving a base case(s). Recursion is a powerful way of solving various problems such as Tower of Hanoi, finding the factorial, finding the Fibonacci sequence, and basically anything that can be solved with iteration and more, yet in a simple, neat, though somewhat confusing manner. One specific time that I know of when recursion is very helpful is when the problem requires a divide-and-conquer way of solving. Anyhow, though I know that recursion is very helpful when programming, I still have not yet got the hang of it as I still often get confused. Nonetheless, it will improve with practice.

Thank you for reading,
pilpho
o(@ _ @~*)o