2015年2月23日星期一

Stack

    Stack is a kind of data type, which is last-in-first-out(LIFO) structure.  Basically, it can be achieved through two methods of list.  As the following, there are some codes demonstrating how it works.
    First of all, we need to initial a new stack.  In other word, we need to create a new empty list.
    Secondly, we can push any element into the stack through using a list method, list.append().

 
    Finally, if we need to delete the top element from stack, we can achieve by using list.pop() method.

    By and large, any elements push into the stack will be on the top of the stack, which will be removed firstly as well.  What's more, all of the operation can be achieved by two list method, list.pop() and list.append().

没有评论:

发表评论