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
Thursday, March 27, 2014
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.
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.
Subscribe to:
Posts (Atom)