Friday, November 29, 2013

Sorting Algorithms


November 29, 2013

TOPIC(s): Listed Above

Over the course of this semester and past year of learning programming, all sorts of new concepts and ideas were introduced, some not so easily as the others. If there was any particular area I was lacking until now, it was in the analysis of algorithm analysis. Thankfully, with the help of the professor, students, and student posts on Piazza I was able to understand this concept better compared to when I first was introduced to it earlier this year.

Sorting algorithms were one of those areas where in terms of both concept and code I had trouble at first. The types the class took a look into were the ever so familiar selection and insertion sort, and as well as some new one such as merge and quick. Out of the ones which I had most confusion on at first was quick sort, where instead of the usual finding an element in a list and doing various comparisons, the algorithm (much like merge sort) took the list and separated it into three elements, a list before the chosen pivot value, and a list after the pivot. It was taking a look after the code with recursion which helped in clarity of the quick sort.

The merge sort on the other hand I found interesting in terms of concept and the code. In concept the list would continually keep breaking down in half until essentially there is one element in new lists, sort itself, and combine with other nearby lists and do the same sorting. In terms of efficiency, I realized that with all the recursive calls called in Abstract way, in terms of sorting large item lists the efficiency would become relatively slow.

With these in mind, it still awes me to wonder how people could come up with many different ways of searching through and sorting through a list. On top of the learned and new methods in this class, there is also the built-in, which is noticeably the fastest in efficiency out of all the sorting algorithms available.


Saturday, November 23, 2013

Week Eleven


Saturday November 23, 2013.

TOPIC(s): [Attributes in Hiding]

This week the class took a turn into more complex features of Python's classes in terms of assigning the initialize attribute statements. Being a relative new programmer before I took the course, I found it understandable why programmers would change variable names in classes, for in order to ensure that the class would function in a certain way the programmer intended it to be. Giving a short example, a unique class of turning a matrix code of numbers into string of words would not particularly involve a float point value. With this topic, the use of exceptions that was introduced earlier in the course broadened, where it was used here in a much stricter environment compared to the traditional "if-else" statements and hierarchy in the "try-except" clauses.

With this topic, I learned various more "properties" and built-ins of Python, such as the property, which takes in methods of a class, and sets the properties of a instance variable name that it is assigned to. So instead of the user calling the methods of the class individually, property takes care of setting the attribute properties in one go, or that is how I thought this built-in takes it. The last interesting feature learned this week was that there are different versions of using recursion. Where instead of calling on the function name directly inside itself, in cases of arbitrary class methods such as __str__ and __eq__, the two items would be compared...

 ex - return one == two
return str(one + two)

within the function body, and recursion is called in this manner.

Monday, November 18, 2013

Week Ten


November 18, 2013

TOPIC(s): [Midterms and Fall Break]

With the last week having been taking two days off and the term test 2 on the day we came back, the past weekend was left to studying the material discussed in the course until now. Here are some general clarifications I have come to realize during the little study period.

Before I had believed that Linked Lists, being initialized as a list in its class definition, was originally a 2 element list with first element being an object, the second being a sequence of nested Linked Lists or an object in its basic case. ex - [2, LinkedList(4)]. But after some more reading it was close, but that Linked Lists were a class consisting of two elements - LinkedLists(4, LinkedLists(3)), where each second element may or may not consist of sequences.

The rest of the material were studied in process of preparing for the midterms.

Sunday, November 10, 2013

Week Nine


November 9, 2013.

TOPIC(s): [Sorting Algorithm and Analysis]

This week the class took into a look at the different types of sorting algorithms. Having learned of a couple already such as the bubble, insertion sort my interests waned into the ones I have not been familiar with - the merge and quick sort.

If I were to summarize what the new sorts were, for my own learning purposes, is that merge sort takes a given list and splits each list into consecutive halves until there is essentially one item in the list, and compares which element in list is greater. And in within each sublist the algorithm would sort itself, and continue comparing with other present sublists until finally the entire list is sorted.

Quick sort on the other hand, designates a "pivid" index to sort the list into two parts: elements found to be larger than the pivid, and elements found to be lesser in value from it. And essentially the pivid value would be inserted between the two parts. Using recursion, another rounds of quick sort is run to sort the other two sublists and then we have the final sorted list.

After writing up the code for the assignment due last Tuesday, I have come to better and fully understand recursion, even if it is a bit late. It was hard to visualize in my case, but for no matter how long the function of a recursive function is, or what variable is passes, the recursive would pass over until essentially.

As the week starts to arrive, I pace myself into finding a more and new understanding Binary Trees and Linked Lists and of revisiting myself in the nifty code tricks such as tuple unpacking learned throughout the months for the utmost testing period coming very soon.


Sunday, November 3, 2013

Week Eight



November 3, 2013.

Topic(s): [ Binary Search Trees and Algorithm Analysis]

This week the class took a brief look into binary search trees and introduced some mathematical forumulae on algorithm search types and their best and worst case scenarios. Having come from a background with nearly no prior computer programming experience other than basics in coding of HTML in high school, I was as good as lost when I was first introduced to algorithm analysis and the efficiency of running a program.

 Particularly in this course and CSC108, the class is using Python in learning the basis of computer functions, syntax and properties, I had no idea as to what the instructors were talking of during the first intro course. But as learning the basis of this topic on a intuitive level in another course, it helped me clear up my understanding on this topic further as the prof talked over the topic of efficiency. And as a person who is very interested in coding when it comes to her own interests such as HTML, phone OS and even gaming, I learned that this subject is a very practical to put to use in real life. That is one important thing which I have come to understand this week.

My only problem that I am facing is a lingering confusion on one part of the recursion topic which was covered several weeks ago. Over the weeks of practising through the exercises and on other files on my own time, this concept was as good as crystal clear. The only confusion I would have was a lingering thought in the exercise 5 that was given, where for the first part of the exercise we had to use recursion in order to take care of assigning instance variables properly according to what they were passed as a value.

If recursion takes care of anyalsis and forming a return value based on what the function/method/program told it to do, how would recursion, in this case, have taken care of assigning proper variable statements in this case?

For example, if the recursion was called in order to find the root of a tree, through searching the most inner-parts, then how would it take care of things such as:

self.root = Node(x)
self.root.left = Node(x, y)
self.root.left.left = ...
self.root.left.left.right = ...
self.right.left.left.left.root.left = ...

And so on. You catch my drift.
All-in-all, other than these confusions I have come to understanding quite a number of concepts as well. And as I am currently working on figuring out the second part of Assignment 2 due this Tuesday, I hope this will help me to understand more concepts, especially in binary strings and so on.

Peace out!
- [insert diagram here] traingle-angel man [/insert diagram]