2014年3月30日 星期日

Algorithm and Efficiency

    We've been learning the efficiency of different algorithms. A good algorithm will have a high efficiency which takes less computer memory and time to process it. Therefore, it is important to understand different algorithms and how to estimate the efficiency (run-time) of functions.

    So far we have learned a few sorting algorithms: insertion, selection, bubble, quick, merge. These sorting methods has different efficiency. Although some of them have the same efficiency on the worst case, it does not mean that they have exactly the same run-time. The Big-O notation ignores the constants, so that, although you might see that they have the same Big-O, it doe not mean that they have the same efficiency. For instance, insertion sort and selection sort have the same efficiency on the worst case. However, we can still find that insertion sort is faster than selection sort if we test them precisely.

2014年3月2日 星期日

Recursion: An Useful/Helpful Coding Technique

    Recursion has been my favorite coding technique since I learned it recently. I found out that it is very useful when I was writing assignment one: Hanoi Tower. Using recursion saves us a lot of time and the code will be a lot shorter since it keeps on calling the function itself until it meets the base case, particularly, when we're dealing with a huge and complicated algorithm. To know how to write a recursion, we have to find the base case first since it is the trigger of stopping a recursion, else the recursion will never end. It is also important for understanding the recursion we are writing. Then we think about the next recursive step in order  to complete the recursion.

    Writing recursion was hard for me at first. The idea of calling the function itself without actually doing anything confused me a lot. Later, I figured out that I was confused since I was not considering about the base case. List comprehension is a lovely recursive technique. I used a lot of recursions when I am coding. Especially, for the tree methods, list comprehension makes life a lot easier for us to understand how the methods were written. Recently, when I am dealing a list of lots of inner lists, I always use list comprehension to sort the list first, then I do whatever I need to meet the function.
   

2014年2月1日 星期六

Week 4

This week in lectures, we learned about recursions which was still a big confusion to me at first even though, during csc108 last semester, I saw a girl wrote a program using recursion and I did understand the simple concept. Professor Heap explained the concept by showing us a turtle. I eventually understood how to write a recursion. Recursion is a function which basically loop itself until it gets to the result we want.

For the labs from the beginning of the semester until now, people in my lab and I all thought that we do not have enough time to actually finish it in class. However, I'm glad that the marks for the lab aren't counting on the correctness of the lab. But still, I finished the labs at home by myself!

2014年1月22日 星期三

Object-Oriented Programming

During the classes of Csc148 these 2 weeks, I've learned a new concept which I've heard from my friend who has been writing programs for years that will help me on writing programs in the future, Object-Oriented Programming. At first, I wasn't quite get the idea when I first heard the professor explaining it in class. Therefore, I searched it on internet and found a lot of paragraphs about it. These paragraphs helped me a lot on understanding the concept. According to the paragraphs, OOP(as known as Object-Oriented Programming) is an opposite concept from the traditional concept. Traditional concept simply sees a program as a combination of functions. However, in OOP, every object can receive, process and give data to another object, which means we can see each object as a different processing machine. Nowadays, OOP has been widely used in large projects since it's easier to design and to repair. More importantly, supporters of OOP claims that it's easier to learn programming since it makes programs easier to analyze, design and understand.

In my understanding, OOP can help me a lot in programming since each object can interact with another, which I believe that the programs I write will be more efficient and faster in the future