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.