CSC148 Progress Report
Thursday, March 27, 2014
Week 11 - Sorting
However, what differentiates these sorting algorithms aside from how they sort is how long it takes to sort a set i.e its performance. Each way of sorting either via Timsort or Selection Sort or any other kind of sort require a number of steps before a set is sorted. For a n sized list, the performance of a sorting algorithm is categorized as either constant where the number of steps required to sort a list is constant non changing, or n where the number of steps depends on the length of the list i.e linear function or n^2 where the number of steps depends on the square of its length or n^3 where the number of steps depends on the cube of its length or nlogn and logn where it takes the log of the length of length for it to complete the sorting or finally 2^n or n^n where the number of steps required is either 2 to the power of the length of the list or the length of list raised to the power of the length of the list. These categories are in Big-Oh which is a way of representing the worse case or the upper-bound for the number of steps it is required for a sorting algorithm to sort a list. The best type of algorithms you have to is categorized by O(c) which means that the worst case for the algorithm is constant. That means that no matter no long your list, it will only do c number of steps. It is constant in that the number of steps do not vary depending on the length of the list. These type of algorithms are the fastest and most efficient. The worst type of algorithms you want to have is categorized by O(n^n) or O(2^n). These are exponential functions and take a huge amount of steps. A list of 5 items if the algorithm is categorized by O(2^n) would already require 32 steps to solve it vs just only 5 steps for an algorithm categorized by O(n). These exponential functions are really really slow and not efficient. Therefore, you want to avoid algorithms with O(2^n) or O(n^n).
As much as you want to avoid algorithms with Big-Oh of exponential functions, you also want to avoid using sorting functions or any type of methods or functions that are not built-in. The reason is that you are not a programmer and therefore the function you write is not optimized for the platform nor is going to work as well as the built-in methods. For example. the built-in sort function worst case is represented by O(n).where as the other kinds of sort that even the prof wrote such as Selection Sort or Insertion Sort still is only represented by O(n^2). This means that the built-in methods is always going to be better than what you can come up with. Therefore, you want to avoid having to write your functions and methods. It is always better to use built-in ones.
Wednesday, March 26, 2014
Week 10 - A2 Part 2
Monday, March 17, 2014
Week 9 - A2 Part 1
The first part of thus assignment for me was really vague. I honestly really had no idea what to exactly do. My group and I had go to through several revisions and complete overhauls of our code in order do create a correct Binary Tree Class. We started off with very little inheritance and eventually realized that most of the code, dependent on how we wrote it could easily be inherited from sub class to another because some of the codes were very similar. Thereby, reducing the amount of duplicate code. That was a hard part of this assignment, reducing duplicate or similar code. By reducing the amount of code and inheriting more of your code, you are able to reduce the chance of bugs and reduce the amount of work you have to do. Reducing the amount of work you have is a crucial and critical part of studying comp sci. The less work you have to do to get the job done, the better.
Week - 8: Linked List
Saturday, March 1, 2014
Week 7 - Recursion
By breaking down the problems into its base cases, it allows to solve many versions of the same problem if they have all the same base cases. Therefore, this technique is really useful to use because it reduces the amount of code. Many of the big problems can be simplified to its base cases and allows you to be lazy and solve the big problem with relatively few lines of code. Being lazy is of the greatest skills of a computer scientist. Also, the code is really efficient in that it doesn't require lines and lines of code. A problem can be solved recursively simply using 1 line of code. Therefore, recursion is really useful technique.
A prime example of using recursion to solve the problem at hand which was moving cheese across the four stools in A. The stools were a nested list where each stool was list that was inside a big list that holds all the stools. Therefore, this was a problem that could be solved very easily using recursion because there were base cases that could be used to solve the bigger problem. The base cases were moving a cheese from origin to destination, and moving two cheese from origin to the destination. By breaking the overall big problem of moving several cheeses across 4 stools into the base case of either moving 1 cheese or 2 cheeses, the solution of the problem was slowly built up. What I mean by the solution was built was that because you know how to move 2 cheeses, you know how to move 3 cheeses and because you know how to move 3 cheese you know how to move 4 cheeses is which just moving 3 cheese plus moving 4th cheese i.e one cheese from the origin to the destination.
Friday, February 21, 2014
Week - 6: A1 Completed
The concept of trees was a fairly simple concept to understand. On the other hand, unit-testing is still a bit difficult for me code out. I still keep on referring back to previous labs and like looking up the API on how to use certain methods in the class unittest. I think I just need a bit more practice on it especially considering its on the first term test.
Sunday, February 9, 2014
Week 5 - A1
The tour.py algorithm for A1 is really really annoying because when trying to find the algorithm, the tracking of which variables are which gets so confusing especially once you add more and more cheeses. I have been lost in my tracking of the variables as to which one are representing which. I don't know how many papers I have scrunched up and threw away because I got lost. However, after finally not getting lost, the feeling of accomplishment was amazing. It wasn't the best solution, but party darn close. The key to figuring it out for me was keeping track of source, dest, int1 and int2 meticulously. I drew everything out on paper and then bamn, everything made sense. Never under estimate the power of paper and pen. It is your best friend when it comes to recursion and you have to keep track of variables that change. Happy tracking.