Home >Common Problem >What is the principle of entry and exit of stack data?
The principle of entering and exiting stack data is first in, last out; the stack is a data structure that stores data according to the principle of first in, last out. The data that enters first is pushed to the bottom of the stack, and the last data is on the top of the stack. , when data needs to be read, data is popped from the top of the stack.
The operating environment of this article: windows7 system, DELL G3 computer
What is the principle of entering and exiting stack data?
The principle of entry and exit of stack data is first in, last out.
The principle of stack
The stack area (stack) is automatically allocated and released by the operating system to store function parameter values, certain values of local variables, etc. It operates like a stack in a data structure.
The heap area (heap) is generally allocated and released by the programmer. If the programmer does not release it, it may be recycled by the OS when the program ends. Note that it is different from the heap in the data structure. The allocation method is similar to the characteristics of the linked list
stack: The stack is a data structure that stores data according to the first in, last out principle. The data that enters first is pushed to the bottom of the stack, and the last data is on the top of the stack. When data needs to be read, data is popped from the top of the stack (the last data is read out first).
The stack is a special linear list that can only be inserted and deleted at one end. Stack items in a bucket, stacking the items at the bottom first, and then stacking them one by one. When taking them away, they can only be taken one by one from above. Stacking and retrieval are performed at the top, and the bottom is generally immobile.
The stack is a data structure similar to a bucket of stacked items. The end where deletions and insertions are performed is called the top of the stack, and the other end is called the bottom of the stack. Insertion is generally called PUSH, and deletion is called popping (POP). The stack is also called a last-in-first-out table (LIFO table)
For more related knowledge, please visit the FAQ column!
The above is the detailed content of What is the principle of entry and exit of stack data?. For more information, please follow other related articles on the PHP Chinese website!