A stack is a linear table that inserts and deletes at one end. The top of the stack---allow the insertion, deletion of this end, the current position of the top of the stack is dynamic change, not allow the insertion and deletion of one end is called the bottom of the stack, the bottom is fixed not to become, when the table has no element is called an empty stack.
Common operations on stacks are:
- Stack initialization: init_stack () initial condition: Stack does not exist operation result: constructs an empty stack
- Judge Null: empty_stack () if the stack is empty, return is 1, otherwise return 0
- Stack: push_stack (s,x) initial condition: Stack s already exists operation result: Insert an element x at the top of the stack s, so that x becomes the new top element of the stack.
- Stack: pop_stack (s,&x) initial condition: Stack s exists and is not empty operation result: the top element of stack s is removed from the top of the stack and saved in the variable X
- Fetch top element: Gettop_stack (s) initial condition: Stack s exists and is not empty operation result: return stack s top element, and the structure of the original stack does not change
- Destroy stack: destory_stack (s) initial condition: Stack S already exists operation result: destroy an existing stack
Storage of Stacks: (1) sequential storage (2) chained storage
Reference: http://blog.sina.com.cn/s/blog_8c5b746601019wxc.html
http://zh.wikipedia.org/wiki/%E5%A0%86%E6%A0%88
Http://en.wikipedia.org/wiki/Stack_ (computing) #Computers
-------------stack for C + + implementation of data structure