As the class processes on, we began to learn algorithm. recursion is a really interesting way to write program. I have found that we could use some simple but talented way to rewrite some complex code. When we use recursion, only few codes we need to write, and computer finishes anything left. it is really a new experience for me to write code. And this algorithm really gives me a new way to think how we should write code and how computer could do.
It's different with C or pascal, I found out that Python is really a better language. It's convenient and clear to show and let us understand how to write and figure out how computer works. But sometimes I still have to figure out these three different language. I often mass them up and make my codes incorrect. It's so lame.
The most important concept I learn is to use the function in the function.
ex:
if instance(L, list):
return max([rec_max(x) for x in L])
else:
return L
This is a convenient way to write recursion but it's hard for me to think about it.
Also, the dot product I learn during the TUT is helpful to understand the concepts and how we write loop in a different, efficiency way.
2016年2月25日星期四
linked list(week6)
Linked lists are a dynamic data structure, which can grow and be pruned, allocating and deallocating memory while the program is running. We learn how to create it by writing two classes, class linked_node and class linked_list while linked_list is a subclass of linked_node.
And there are totally four parameters we have to think about, value, next, front and back.
Insertion and deletion node operations are easily implemented in a linked list by creating 'def append' and 'def deleted'. Also, we can also decide the position where we insert or delete.
Linear data structures such as stacks and queues are easily executed with a linked list.They can reduce access time and may expand in real time without memory overhead
2016年2月11日星期四
test (Week 5)
The first term test seems easy, but I still have struggling on how to write a blueprint of the whole program. I am confused about how to set up different functions into different classes. Sometimes I just can't figure out If I have to create a new subclass or not.
abstract data type and stack(Week 4)
The abstract data type is a new thing we learnt this week. It is a mathematical model for a certain class of data structures that have similar behaviour. The stack is a specific thing we are getting to. There are three basic functions we are using usually, push, top, pop.
I think the between with stack and queue is that stack is first in first out, queue is first in last out. but sometimes I still confused about how actually we could create a stack or queue with python and use them.
I think the between with stack and queue is that stack is first in first out, queue is first in last out. but sometimes I still confused about how actually we could create a stack or queue with python and use them.
订阅:
博文 (Atom)