This week we covered various kinds of sorts. Some of them include selection, quick, merge, and tim sort. Of the sorts mentioned, we go from slowest sorting time to fastest respectively. Reasons for this were analyzed in class, mentioning how selection sort iterates n time to see what needs to be swapped, then another n times to swap. This results in O(n^2) time, as opposed to merge sort which cuts the list in half each time, then joines them back together, the join in itself is about n times, but the splitting is log(n), yielding a combined time of n log(n) time. Now we just observe these sorts based on their strict algorithms that do the same job yet in a different way, so why not combine all these sorts to form a gigantic one that does the job best in certain scenarios? Well that is the definition of tim sort, made specifically for Python.
Finishing up BST's we covered deleting from a BST and forming linked lists out of them. This was fairly challenging because creating the Linked List nodes required you to remember that once an object is created on the stack in python, it stays there until the code is done with it, so if you create a linked list node in the call, it is that object that will be within the prior. This was a key component to solving the lab and caused great pain for my partner and I to solve. Other than that BST's were fairly straight forward and I can see great applications of this being to store a list of contacts or numbers where indexing is crucial.
Tuesday, March 25, 2014
Sunday, March 16, 2014
Week 9 - Projects and Stress
This week we have our exercise due, and the second part of our second assignment due next week. I have finished the exercise and just checked my automarking results. Thankfully they show perfect, but for our second part of assignment two I am quite puzzled. The assignments in computer science are pretty vague and I always feel as if they do not teach you everything you need to know for them. Sure, the tools we use are all taught, but the concepts are quite advanced, mainly the cheese algorithm in the first assignment. It's a pleasure getting to deal with such high level algorithms, but it's also scary when your mark is on the line. I've actually gotten a partner for the first time this year to help me out with this assignment, so this collaboration is certainly new and welcomed.
Other than projects in computer science, I have a job application I'm currently working on. The program I need to build for this application is far more advanced than the topics we cover in first year computer science, so hopefully I have enough energy to see me through this test.
Other than projects in computer science, I have a job application I'm currently working on. The program I need to build for this application is far more advanced than the topics we cover in first year computer science, so hopefully I have enough energy to see me through this test.
Tuesday, March 11, 2014
Week 8 - Linked Lists
This week we covered linked lists and talked about how they are data structures which are made of nodes that point from one to another. The nodes are represented by objects and contain pointers allowing for a way to explore the list iterating from one object to the next via pointers. Linked lists can come in two forms. One being a singley linked list allowing for appending and deleting from the end, and doubley linked lists that can be appended to and deleted from both the beginning and end of the list. This data structure differs from that of a normal list or array in the sense that it is not indexed, and the only way to explore the list is through iteration. This being the case, exploring and finding an element in a linked list will take O(n) time.
In addition to linked lists we talked about binary trees and demonstrated methods that were used in the __repr__ method to make them more humanly readable. It is through this demonstration that we saw the power of the traversal techniques learned in the prior weeks.
Subscribe to:
Posts (Atom)