Wednesday, 19 February 2014

Recursion

   In past few weeks' study ,we've learnt that the conception of the recursion,as I wrote before,ttp://tmaftbbwaatmm.blogspot.ca/2014/02/first-impression-about-recursion.html the first impression about recursion.
   However, when we learnt how to express recursion by trees, which was more obvious and more complicate than list expression, I found that the my first impression was not so accurate.
   For list impression, recursion is like to repeat the same operation from biggest to smaller unit.It looks like a linear structure,starts from a known point and ends at a fixed destination where there is no smaller unit to run.Writing list recursion might be efficient to avoid duplicate code. But for some common and easy cases, I couldn't see apparent advantages to use the recursion expression.
  When it comes to the trees structure, the superiority of recursion grows clearly.A typical binary tree structure is made up by nodes.Top of the tree is called root and others are called branches.The group of branch nodes with the same reference is called the leaf. By expressing in this way, we can adjust only a leaf of the tree or the root of the tree.I think, which is opposite from the lists, trees starts from the same root by ends at the different endpoints. That leads many different paths while running a program. Still, the operations keeps going to the smaller levels, that's the foundation of recursion. But there is no doubt that the tree structure fits the complexes better.

Assignment 1- TOAHModel

    For week 6,I was busy with programming assignment 1.
    It was being divided into 3 parts, TOAHModel.py, ConsoleController.py and Tour.py. In my understanding,  TOAHModel was to build all the classes that we needed in this assignment. It included cheese class, TOAHModel class and MoveSequence class. Cheese class is to make to basic object in the TOAHModel. TOAHModel is to design model of stools to move cheeses.MoveSequence is to record and adjust the moves while moving cheeses.
   This kind of design inspired me to split the program from their different goal.

Saturday, 1 February 2014

First Impression about Recursion

    In the week,I mean week#4, we formally started learning recursion. 
    Defined by the Python 3 document, Recursion means defined something in terms of itself(usually in smaller scale) to achieve objective in multiple times.
It is like the picture showing below.



Showing from the picture,the recursion is like a chain of endless order.In class,first of all,we dealt with the simple list,then nested list. Those nested list gave me the first impression of recursion,which is its high efficiency and concision.For only one line of code all items in nested list can be sorted.And amazingly, fit in every kind of item.
But I still haven't written my own recursion code yet,I think I have to rigorous about determining where is the recursive part.It could be like for loop or while loop,I guess.