Wednesday, March 30, 2016

Week 11 Slog: Last Impressions and Sorts

In the last couple of weeks, we learned between different algorithms result in different efficiency. A good algorithm can provide extremely high efficiency while a bad one cannot. As a computer science student, it is important to understand algorithms and learn how to evaluate the efficiency of functions. Throughout this course, we learned several sorting algorithms, including bubble, insertion, selection, merge, quick. They are using different methods of sorting and therefore having efficiency are different. However, I find that we shouldn't choose algorithms only base on their efficiency on the worst case, since sometimes our function would be used in some kind of specific data, and that might be not in worst case. Consequently, when we are choosing algorithms, we should consider both the efficiency of the algorithms and the condition of our target data or what our function to be used for.
Aside from reviewing my thoughts on sorts, I would also like to write down my thoughts and impressions of this course. CSC148 was overall an interesting yet challenging course. Recursion, linked list, binary tree, etc., none of the above topics were easy for me, and I often find myself struggling in class and during labs. Fortunately, I had a group of helpful labmates (and TA) who got me through this semester. This course also took me through the ups and downs; I did extremely well on the first midterm and extremely bad on the second one. This is actually a good opportunity to learn and adapt different feelings, and instead of getting stuck with depression and other sadness, I have to overcome it and move on. The exam is coming soon, and to be honest, I'm confident at all, but I will try my best to get myself prepared.
As I mentioned above, this course contains many conceptual and difficult topics l. I personally found recursion the most difficult. Even by learning one step at a time with patient, I still found this particular concept hard, especially writing and implementing the recursive code. I discovered several solutions to help myself with. One way was to visualize the implementation of the code. For instance, I draw diagrams for the use of recursive code in binary tree. I believe what I learned in CSC148 is important as they are the basis of computer programming and I hope these foundational contents will assist and inspire in the future.

Wednesday, March 9, 2016

Week 8

This week, we learned about Binary trees and Binary Search trees, a way of organizing data in trees such that they are easier and more efficient to search through. In class last week, we wrote a function called insert that inserted data starting at node, and returned the root. We examined the code (def insert) and talked about a new function for deleting data instead of inserting data. In the function for inserting data, we wrote a recursive function. Taking in a node and data, the function should insert the data at the node and return the root. Starting by assigning the node to a new variable, called return_node, we then wrote an if statement for the simplest example, where there is no node (if not node:), if that is the case, then the variable return_node should be assigned the new data. If the new data is less than the data at the node, then the data is inserted in the left node, else if it is greater than the data at node, then it is inserted to the right. This is a property of binary search trees (greater values are on the right and smaller values on the left of the node). Finally if there is nothing else to do, (else statement), return_node should be returned. This code is easy to understand, especially after breaking it down like I did above. By going through the code line by line and "reading" the if's, elif's and else statements, you can understand what the code does, even if there is no docstring description.