Review the 7 points of the stack ADT

Source: Internet
Author: User

1. Simply put, the stack is a table for inserting and deleting operations in one place, and this particular position is the end of the table, but this is not the end of the stack, but the top.

2. Stack in the basic operation of the stack and the stack, the English name is push and pop, respectively, equivalent to insert and delete. Remember that pop and top operations on empty stacks are considered wrong on stack ADT, and if push is implemented outside of space there are implementation restrictions, but this is not an ADT error.

3. The characteristics of the stack is the last-in, first-out, for students may be piled up in the canteen to describe more suitable dishes.

4. Stacks can be implemented either with a one-way linked list or by an array. It is relatively simple to use one-way linked list, but it is relatively simple to use an array to achieve it, since it can be _back with the back, push_back and pop of the vector. And with the array, each stack will have a thearray and topofstack, for the empty stack this topofstack is-1, if you want to add an element x, then Topofstack plus 1, and thearray[topofstack]=x. If you want to delete an element x, then the return value of the POP function is Thearray[topofstack], and remember to subtract the Topofstack by 1.

5. The above operation is very fast, and if there is a self-increment and self-reduction of the function of the register, then the whole number of push and pop operations can be written as a machine instructions oh.

6. The information stored is referred to as the activity record, or the stack frame.

7. About recursion, if you are interested, you can look at this article, it is very likely to expand your knowledge.

Portal: "Scheme induction" 3 comparison do, let, loop

Review the 7 points of the stack ADT

Related Article

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.