2015年4月8日星期三

Week 12

Say something to farewell to CSC148

      A course doesn't mean something when you select it on the ROSI. But, at once you finish it, you

 will appreciate it for teaching so much interesting knowledge and the growth you get in the process. 
      
     Thanks Mr Danny and all the hard-working TAs for arranging the lab and assignments and

solving our questions. You really do a good job no mater with the unexpected strikes.

    Let me talk something about the knowledge about CS I learned in the course.  Without doubt,

recursion is the key point and most useful, challenging knowledge. I dare say it greatly broaden my

minds when confronting with a problem. With this tool, we could take a good advantage of computer

to finish a lot of work with good efficiency.

    Besides, by learning many ADTs(abstract data structure), I am able to model many things in

realise, which reminds me that many real life things could be solved by computer after modeling the.

    Last but not the least, all three assignments really promote  my competence of debugging and urge

me to develop a good habit of programming with restrict format.

   Good-Bye! CSC148. Thanks for making me grow.

2015年3月25日星期三

Week 11

Turn back to see my steps left behind
    At my first slog of 148. I said I does not like any form of writing.  How naive am I? 

    Emotion and attitudes are a reflection of our innermost being. Why don't I not writing? To be 

honest, I do not feel confidence about my writing skills and do not want this become a factor 

affecting my grades. It is just an excuse for me to escape from confronting my weakness. 

    I really need to adjust my mind. Talking and words are really plain to express our feeling exactly.

 But when I typing all of this, my minds are thinking of many things. Introspection is always good 

and let us have a rest to comb our life and adjust the direction of the goal. 

    Life is full of change, calm down and take it. Nothing is not could gonna make it. So, why should 

I  be frustrated? Such a great life, so many helpful friends, caring family, all devoted instructors and 

even the strangers who once smiled towards you.

   I need turn my head and move on.

Week 10

Trace your calls and debug your function
  • Making assertion
  • Trace calls
    This week, we did not learn much but some evaluate and debug method to test your 

code.

    Without question, debugging is so familiar to us ---- a programmer. With the complication 

of the code grows, we always spend lots of time to debug code. Sometimes, you may finish 

the code for 1 hour but debug it for 4 hours.... I still could feel the anxiety when I am stuck 

by a bug. 

    Since, it is so common in programming. We have to learn some systematic methods to 

be applied to fix all bugs in step by step with high efficiency.

    1. Making assertion. Making assertion is actually just let the computer to examine if the code 

output the result as we want rather than need us to print it out and compare it with our expectation. 

The tool is often used in unittest to compare expected result and actual result.

    2. Using the debug tools built int the Wing could also enable us to analyse our code in a visible 

method. We could check whether the variable changes as we want as the code running.

    I seldom complain the experience of debugging. I believe it is also a good exercise for me to 

program in more strictly mind and help me accumulate the experience of fixing different kinds of 

debug problem.

   More you practice, more you learn.

2015年3月15日星期日

Week 9

Know more about Binary Search Tree
  • Efficiency of Binary Search Tree
This week Danny lead us learn more knowledge about BST(Binary Search Tree).

First, we come to discuss of the efficiency of the BST with the initial insert method. 

For example, to an empty BST, if we insert 10 numbers from 1 to 10 with increasing or decreasing order. One of the Tree will be like:
The other one is almost same but with converse numbers. Obviously, the height is so high. The BST does really a bad job to the inserting numbers that have been in ordered before.In other words, to numbers in certain order, BST could not display its special features.

So how we deal with that. By the lab I find we could use random module to change the inserting order of the numbers in a number list. Like this: 

import random
while number_list:
   num = random.choice(number_list)
   number_list.remove(num)
   bst.insert(num)

Although it could fix the problem in some way, it is not a perfect method. We should find the key part of the problem is that out BST could not adjust its existing structures to fit the new inserting number. Hence, we have to optimize the initial insert method.

  I have not come up with some great idea about this. I need to think of it for some days. 

2015年3月8日星期日

Week 8

Linked List - Why you could be so long?
  • Linked List Node
  • Linked List
  Such a busy week because of the assignment 2 which I really put a lot of 

efforts in it. Confronting with tons of different bugs keeping optimizing the 

construction. Although it made me wore out, but I find that my significant

 progress in competence of debugging and the understanding of recursion.

 Here comes to the point. This week ,I learned LLNode and LinkedList. To be

 honest, at first I did not understanding what they are. But then, after 

finishing the practice of lab handout, I find its amazing features.

 At first, LLNode is the composition of a LinkedList. It is a ADT that

contains a value and a successor variable which could be used to point at

another LLNode. Because of the existence of this variable we could link tons

of LLNode together.

 Hence, another class called LinkedList is invented to construct these LLNodes

together with specify its heading(front) and tail(back). Just like a snake 

game, which could keep elongating without limits, which is even more special 

that it could add elements from the front.

 By the way, with creating many methods, we could use it to implement some 

functions like indexing, append, insert and delete...

 There is a very tricky place when we want to insert a LLNode in the LinkedList.

Here is a case that I want to insert a LLNode(2) into the LinkedList that LLNode(1).nxt = LLNode(3)

Firstly I have to change the LLNode(2).nxt = LLNode(3), then I change the 

LLNode(1).nxt = LLNode(2).The key here is that, if you change the LLNode(1).nxt =

LLNode(2) first, we will lose the ability to find LLNode(3). Hence, we should 

use LLNode(2) to aim at LLNode(3) at first then change the LLNode(1).

  I believe, LinkedList must have many other interesting and amazing latent energy.

  More practice, more you will learn.



2015年2月26日星期四

week 7

More recursion in Binary Tree
  • Binary Tree
  • Recursion
  • Abstract Data Type
 This week, we learn “Binary Tree” based on the ordinary ADT "tree" from the last week.

 "Binary Tree" is distinguish from the ordinary tree that every node has none or no more than 2 children which are also distinct from each other, the left children has the value less than its parent node's value and the right children should has the value greater than its parent node's value.
  
  Although at first sight, I think it is not that good but even troublesome when act as a data type to store data . 

  Since, it it works as a data type that used to store things, it has many weaknesses for example it could not guarantee the sequence of a series of numbers and I couldn't find a number by calling its index. However, when it function as a dictionary, it will display its powerful latent energy. For example:
For example, in the Binary Search Tree(BST) like above and a list contain [8,4,9,3,5,10]. If I want to find out whether 10 is in it. I only need one step(by the special property of BST, from 8 I could go straight to the right to the 9 and then to the right side get 10, total 2 steps!) but need 5 steps in the list.

Another example, if I want to find 5, I just need 2 steps(from 8 I could go straight to the left side and then go the right side of 4 which is 5, total 2 steps).But need 4 steps for the list.

With the n the elements it need only about log2(n) steps to find it out,which is much faster than any other data type.

 More you practice,More you will learn.

2015年2月11日星期三

Week 6

Winter is leaving 
&
Reading Week break is coming
  • Tree - A new useful ADT
The last week before Reading Week Break, which I am really looking forward to 
although I still have no girlfriend to celebrate the Valentine's Day(So sad...)

This week, I learn a new abstract data type which is called - Tree. It just looks
like a tree diagram, with some terminologies like root, node, children, edge,
leaf, height, depth etc. The Tree is created with the base of recursion, because 
every node with its children could be thought as a individual tree. 

By this recursion features, we could use it to quickly and efficiently search some information about every elements.

I once heard a concept 'Binary Tree', which seems to be a very useful ADT to 
store information with some features like magnitude or something which could 
greatly facilitate us to search something.

I believe Tree has much more interesting functions and applications, which needs me to explore.

By the way, the Chinese New Year is coming, which is also my sister birth year.
I wish all my family could live a healthy life and everyone could feel the beauty
of life and cherish the people around you.

2015年2月5日星期四

Week 5

A tired week
  • Quick Sort
  • Stack & Queen
 Test,test,test..Do you wanna some more test? No!!!!!
 I've been through three tests this week, which almost wear me out.I have no energy to make complains. Here comes the slog:
 This week, Danny demonstrates a so called 'quick sort' sort method that could sort a list of number very quickly(forgive my plain words).By the help of the super powerful recursion, just few steps, every number are sorted.
 Here, is my analyse: For a given series of numbers: L=[6, 2, 5, 7, 1, 4, 3, 8]
 First, we choose the first elements as a flag, in this case is 6. 
 Second, every other number has to compare their number with 6, if it is smaller than it, insert to the left of 6. If it is greater than it, inset to the right of 6.
 Then, we get [3, 4, 1, 5, 2, 6, 5, 7, 8]. Now we just have to consider to sort the two sides' numbers of the number 6. 
 For the left part [3, 4, 1, 5, 2]. We repeat the above first and second steps, take 3 as a flag, then rearrange other numbers, then we get [2, 1, 3, 4, 5]. 
 By some check, repeat these steps until all numbers all sorted. Hence, we do it again, take 2 as a flag, then rearrange orther numbers, then we get[1, 2, 3, 4, 5]. The right side is the same.
 Less swap numbers means quicker sort, which is really useful by using recursion to complete such a problem. 
 Besides, I learned a new ADT(Abstract Data Type). Just like list, tuple and dictionery. We could use class to custom our own wanted ADT. 
 We can use a stack to check whether parentheses are balanced. It is featured
that the last item in is the first item out, which could be called 'LIFO'.Unlike
stack, queue is converse, which is 'FIFO'.It can be used to simulate the actual
world like a real queue. First people in the line should be the first to get 
out.
Ok, that's it. I need to take a bath and have a good rest.

2015年1月29日星期四

Week 4

Recursion - Such a mysterious and powerful tool !
  • Recursion
  At the first sight of the word 'Recursion', I thought it is the same as 'Loop' or 'Iteration'. But, actually, it owns the very different principle. 

  Before I learn recursion, I might do a math of computing 1 + 2 + 3 + .. .+ 100 with a loop like:
sum = 0
for i in range(101):
  sum += i
 After I learn recursion , I will do like this:
def gs(x):
 if x != 0:
   return x + gs(x-1)
 else:
   return 0
  To my mind, I think the essence of recursion is to allocate a task into several small pieces with the same operation method. Because, the best thing that a computer to do is to repeat a thing for thousands of times.
  Hence, recursion just takes this advantage to solve some very heavy but actually simple and repeated work.However, the most important and difficult thing is to analyse a task and could think of that it could be allocate into many small simple tasks.And then, write down their relationships by codes, which is such a challenge and needs many tons of practice.
  In a word, more you practice, more you learn.

2015年1月22日星期四

Week 3

Hello CSC148!
  • Slog
  • Inheritance
I thought I have said good buy to Slog after CSC165. But...


To be honest, I do not like writing in any form. Undeniably, writing things down really do a better job for us to reorganize our mind and help us to clarify out thoughts to others more explicitly, which makes me to take it serious and do a great job of the last session. Apart from this, team work is very important for programming a very large project, which requires enough communication for programmers to change there thoughts and make adjust to each other. Hence, I will keep going on without any complains.

The first interesting concept of programming is Inheritance. Because I learned some languages before by myself, hence, the concept rings a bell to me. 

literally, inheritance just indicates a relationship between two classes. class B(A) means that subclass B owns all attributions and methods of superclass A. Moreover, B could choose to add more attributions and methods or even override(overwrite) the method of A for some peculiarities of B, which allows us to make the subclass more complex by inheriting the base of the superclass. 

Besides, we could use one superclass to create many other subclass which shares some similar features but more special peculiarities.

More you practice and more you will learn.