-------------stack for C + + implementation of data structure

Source: Internet
Author: User

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:

    1. Stack initialization: init_stack () initial condition: Stack does not exist operation result: constructs an empty stack
    2. Judge Null: empty_stack () if the stack is empty, return is 1, otherwise return 0
    3. 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.
    4. 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
    5. 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
    6. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.