Current location - Loan Platform Complete Network - Big data management - What is meant by stack
What is meant by stack
Question 1: What is meant by stack? Heap and stack are two different concepts. Memory allocated on heap (heap) is not released by the system and it is dynamically allocated. Memory allocated on the stack (stack) is automatically freed by the system and it is statically allocated. The runtime stack is called the stack. The stack is allocated from the high address of the memory to the low address, while the opposite is true for the heap. Memory allocated by malloc or new are allocated memory from the heap, the memory allocated from the heap must be released by the programmer himself, with free to release, otherwise the memory will always be occupied and not released, there is a "memory leak (Memory Leak)". This will cause the system's allocatable memory to become less and less, resulting in a system crash. A stack is a data structure that performs a "last in, first out" algorithm. Imagine a bamboo tube with a small diameter, open at one end and closed at the other. There are several numbered balls, the diameter of which is slightly smaller than the diameter of the tube. Now put different numbers of balls into the bamboo tube, you can find a law: the first put in the ball can only be taken out after, and vice versa, after the ball can be taken out first. So "first in, last out" is the characteristics of this structure. Stack is such a data structure. It is in the memory to open up a storage area, the data one by one sequential deposit (that is, "pressed into - push") in this area. There is an address pointer that always points to the data cell where the last data pressed into the stack is located, and the register that holds this address pointer is called the stack indicator. The cell where the data is first placed is called the "bottom of the stack". Data is deposited one by one, this process is called "pressing the stack". In the process of pressing the stack, every time a data is pressed into the stack, it is placed in the back of a unit connected to the previous unit, and the address in the stack indicator is automatically increased by 1. When reading these data, the data is read in accordance with the address in the stack indicator, and the number of addresses in the stack indicator is automatically decreased by 1. This process is called a "pop-up pop". This process is called "pop", which realizes the principle of last-in-first-out. The stack register is the register that holds the stack.

Question 2: What is the concept of a stack A stack is a space carved out of memory for storing data

It expands from the large address of the memory to the small address

It is used to store the parameters passed during a function call

The static variables are stored in the static memory area of the program. It is in the back of the program closest to the front end

Question 3: What is a stack and what does a stack do A stack is a common method of characterization used in fiction, usually for a minor character. As an example, a certain swordsman is very hung and is known as invincible. However, a minor character defeats him in a head-to-head fight with him without using any tactics, showing his amazing strength. This is a stack on this minor character, in order to convert him through the conversion of the enormous strength of others into the prestige of this character. This is the stack

Question 4: What is called the stack in ancient times for the storage of goods used in the building. The poem "Xiao Ya" has "Nai Nai". Xiaoya" has "is to seek a thousand Silo" sentence, it can be seen that the warehouse building has a long history. Modern warehouses are more considerations on the operational benefits and not only for storage. This is the difference with the old warehouse. Therefore, the modern warehouse from the transport turnover, storage and construction facilities on the importance of the reasonable layout of the channel, the distribution of goods and the maximum height of the pile, and the configuration of cost-effective mechanized, automated access facilities to improve storage capacity and efficiency.

Warehouse by the storage of goods in the warehouse, transport and transmission facilities (such as cranes, elevators, slides, etc.), access to the warehouse pipeline and equipment, as well as fire facilities, management rooms and other components. Warehouse according to the form of stored items can be divided into storage of solid items, liquid items, gas items and powdered items of the warehouse; according to the nature of stored items can be divided into storage of raw materials, semi-finished products and finished goods warehouse; according to the form of the building can be divided into a single storey warehouse, multi-storey warehouses, cylindrical warehouses.

Single-story warehouses are suitable for storing metal materials, building materials, ores, machinery products, vehicles, oil, chemical raw materials, wood and its products. Water transport terminal warehouse, railroad transportation warehouse, air transportation warehouse with single-story building to speed up the loading and unloading speed. The general layout of the single-story warehouse requires a through road, loading cars, forklifts can be directly in and out of the warehouse. This warehouse is generally used prefabricated reinforced concrete structure, column network is generally 6 meters, the span of 12 meters, 15 meters, 18 meters, 24 meters, 30 meters, 36 meters, etc.. Ground stacking load of the warehouse, the span should be large. Crane lifting capacity of the warehouse according to the maximum weight of a single piece of stored goods to determine. Lifting capacity of 5 tons or less can be used single beam crane or monorail hoist, more than 5 tons with a bridge crane. Warehouse requirements moisture. If for the storage of flammable products, should be used to prevent the production of flexible ground layer sparks. Roofs and walls should be watertight and watertight.

Multi-storey warehouse General storage of department stores, electronic equipment, food, rubber products, drugs, medical equipment, chemicals, cultural products, instruments and so on. The ground floor should be unloading loading site, loading and unloading vehicles can enter directly. Vertical transportation of goods generally uses 1.5 to 5 tons of freight elevator. Consideration should be given to loading cargo cart or forklift can be driven into the elevator room to speed up the loading and unloading speed. Multi-storey warehouse commonly used slide unloading. Slide with reinforced concrete structure, terrazzo waxing for the surface; also available metal skeleton, steel plate surface, but to prevent rusting steel or stainless steel plate for the surface. Multi-storey warehouses such as unit load greater than 500 kilograms, can be used without beam floor cover. Warehouses are generally not painted, ridge slurry hook white can be; storage of department stores, medicines, food, clothing warehouses to be painted to prevent the seam hidden insects. Multi-storey warehouses in the "three-dimensional warehouse" storage and lifting the application of electronic computers to achieve mechanization. This kind of warehouse covers a small area and saves manpower, but the category of stored goods has a certain range.

Cylindrical warehouse General storage of bulk cement, dry ballast, fly ash, bulk grain, oil, gas and other gases. The architectural design of the cylindrical warehouse is determined according to the type of stored items and the way of feeding and unloading. The roof, walls and bottom of the warehouse must be waterproof, moisture-proof, the roof of the warehouse should be equipped with a dust-absorbing device. In order to facilitate daily maintenance, to set up hanging holes, manholes (library wall ladder), measuring warehouse holes and lifting hooks and so on. Cylindrical warehouses are generally cast-in-place pre-stressed reinforced concrete structure, with slipform construction. Oil storage and gas storage with metal structures. To pay attention to the ventilation of the warehouse, each storey of the warehouse should be set on the outside wall of the shutters, shutters plus metal mesh, in order to prevent birds. Hazardous materials such as oil storage (gas) or storage of chemical raw materials warehouse must be heat and moisture, heat insulation layer on the roof or according to the explosion-proof roof design, the entrance and exit set up a fire partition wall, the ground with non-sparking materials, generally available asphalt floor. Oil storage tanks should be set up to collect oil pits. Food warehouses to prevent ants and bees.

Question 5: What is the meaning of the stack In the computer field, the stack is a concept that can not be ignored, but many people, even computer professionals, did not make it clear that the stack is actually two data structures.

Key points:

Heap: sequential random

Stack: first in, last out

Difference between the heap and the stack

I. Preparatory knowledge - program memory allocation

A program compiled by the c / C + + compilation of the memory occupied by the program is divided into the following parts

1, the stack area ( stack) - by the compiler, the compiler can not be compiled. The stack is automatically allocated and released by the compiler to hold the values of function parameters, local variables, etc. It operates in a manner similar to that of a data structure. Its operation is similar to the data structure of the stack.

2, heap - generally allocated by the programmer to release, if the programmer does not release, the end of the program may be recycled by the OS. Note that it is not the same thing with the data structure of the heap, the allocation is similar to the chain table, huh.

3, global area (static area) (static) -, global variables and static variables are stored in a piece of the initialized global variables and static variables in a region, uninitialized global variables and uninitialized static variables in another adjacent area. - After the end of the program is released by the system

4, text constants area - constant strings are placed here. After the end of the program by the system to release

5, program code area - to store the binary code of the function body.

Second, the example program

This is a predecessor to write, very detailed

main.cpp

int a = 0; global initialization area

char *p1; global uninitialized area

main()

{

int b; stack

> char s[] = abc. > char s[] = abc; stack

char *p2; stack

char *p3 = 123456; 123456\0 is in the constant area, p3 is on the stack.

static int c = 0; Global (static) initialization area

p1 = (char *)malloc(10);

p2 = (char *)malloc(20);

The area allocated to get the 10 and 20 bytes is on the heap.

strcpy(p1, 123456); 123456\0 is placed in the constant area, and the compiler may optimize it to be in the same place as the 123456 pointed to by p3.

}

II Theory of Heap and Stack

2.1 Application Methods

stack:

Allocated automatically by the system. For example, declare a local variable int b in a function; the system automatically opens up space on the stack for b

heap:

need to be requested by the programmer himself, and specify the size, in c malloc function

such as p1 = (char *)malloc(10);

in C++ with the new operator

e.g. p2 = (char *)malloc(10);

But note that p1, p2 themselves are on the stack.

2.2

System response after application

Stack: as long as the remaining space on the stack is greater than the requested space, the system will provide memory for the program, otherwise an exception will be reported for stack overflow.

Heap: First of all, you should know that the operating system has a chained list of free memory addresses. When the system receives an application from a program,

it traverses the chained list and looks for the first heap node that has a space larger than the space applied for, and then deletes the node from the chained list of free nodes and allocates the space of the node to the program. at the first address of this allocation, so that the delete statement in the code can correctly free this memory space. In addition, since the size of the found heap node may not be exactly equal to the size of the request, the system automatically puts the excess back into the free chain table.

2.3 Limitations on application size

Stacks: On Windows, a stack is a data structure that extends down to the lower address, which is a contiguous area of memory. This sentence means that the address of the top of the stack and the maximum capacity of the stack are predefined by the system. Under WINDOWS, the size of the stack is 2M (some say 1M, in any case, it is a constant determined at compile time), and if the application space is more than the remaining space of the stack, it will prompt the overflow. Therefore, it is possible to get the stack from the stack ...... >>

Question 6: What is a stack? A stack is a data structure that performs a "last in, first out" algorithm.

Imagine a bamboo tube of small diameter, open at one end and closed at the other. There are a number of balls with numbered diameters that are slightly smaller than the diameter of the tube. Now put different numbers of balls into the bamboo tube, you can find a law: the first put in the ball can only be taken out after, on the contrary, after the small ball can be taken out first. So "first in, last out" is a characteristic of this structure.

A stack is such a data structure. It is a storage area in memory, the data is deposited one by one sequentially (that is, "pressed in - push") in this area. There is an address pointer that always points to the data cell where the last data pressed into the stack is located, and the register that holds this address pointer is called the stack indicator. The cell where the data is first placed is called the "bottom of the stack". Data is deposited one by one, this process is called "pressing the stack". In the process of pressing the stack, every time a data is pressed into the stack, it is placed in the back of a unit connected to the previous unit, and the address in the stack indicator is automatically increased by 1. When reading these data, the address in the stack indicator is read according to the address in the stack indicator, and the number of addresses in the stack indicator is automatically decreased by 1. This process is called a "pop-up pop". This realizes the principle of last-in-first-out.

The stack is one of the most commonly used data structures in computers, for example, function calls are implemented on the stack.

Stacks can be stored in arrays, or in linked lists, which will be introduced later.

The following is a structural definition of a stack, including a top-of-stack pointer, and an array of data items. The stack top pointer points to -1 at the beginning, then when you deposit data, the stack top pointer is increased by 1, and when you remove data, the stack top pointer is decreased by 1.

#define MAX_SIZE 100

typedef int DATA_TYPE;

struct stack

{

DATA_ TYPE data[MAX_SIZE];

int top;

};

Question 7: Briefly describe what a stack is and the process of getting in and getting out of a stack Stacks are actually two data structures. Stacks are data structures in which data items are ordered and can only be inserted and deleted at one end

(called the top of the stack)

of the data items. Key points: Heap, random order. Stack, Last-In/First-Out.

There are two basic operations for a data structure like a stack: press and pop.

In a stack frame, there are two flags ---- the bottom of the stack and the top of the stack, where the top of the stack identifies the address of the data to be pushed or popped

and the bottom of the stack indicates the memory address of the last piece of data in the stack frame.

In Win32, the register esp holds the pointer to the bottom of the stack, and the stack grows in the direction of the lower address,

so esp points to the top element of the stack

Stack Comparison (Operating System):

Allocated and freed automatically by the compiler, it holds the values of function parameters, local variables, etc. It also holds the values of local variables. The

operation is similar to the data structure of the stack in the stack is used in the first level of cache,

is usually called in the storage space, the call is released immediately after the completion of the

Heap (operating system):

generally allocated by the programmer to release

If the programmer does not release, the program may be recycled by the end of the program by the OS recovery, the way of allocating the reverse is The allocation method is similar to a chained list.

The heap, on the other hand, is stored in the L2 cache, and its lifecycle is determined by the VM's garbage collection algorithm (it is not reclaimed once it is orphaned). So the speed of calling these objects is relatively low

Heap (data structure)

: The heap can be viewed as a tree, e.g. heap sort

Stack (data structure)

: A LIFO data structure

Different languages have different descriptions, check the api for the respective language

What is a stack? Question 8: What is a stack? What is the purpose of the stack? Satisfied with the answer enthusiastic askers 2011-06-22 stack is actually the result of the data in the two concepts , is the way to store the data , heap : order at random ; stack : back into the first out (Last-In/First-Out). To say that the usefulness, that is, when writing code, sometimes data access must be a prescribed order, this is your own rules, and then according to the characteristics of the use of the program you write to use the heap or stack or queue and so on the order of Q: program design, why the stack pointer SP re-assignment? Answer: This is not the initialization of the stack is a special storage area, the main function is to temporarily store data and addresses, usually used to protect the breakpoints and the scene. It is characterized by the principle of access to data in accordance with the first-in-last-out principle, where the in and out refers to the stack and out of the stack operation. 80C51 on-chip RAM part of the cell can be used as a stack. There is an 8-bit stack pointer register SP, Dan used to point out the current top of the stack is which cell of the on-chip RAM. 80C51 microcontroller system reset after the initial value of SP is 07H, that is, it will start stacking information from the 08H cell of the internal RAM. However, the stack area of 80C51 series is not fixed, as long as the value of SP register can be changed through software to change the stack area. In order to avoid the working register area and the bit addressing area, the initial value of SP can be set to 2FH or a larger address value. If the CPU is to use two sets of working registers in operation, the initial value of SP should be at least 0FH or greater if no bit variables are used, and at least 2FH or greater if bit variables are used; the KeilC51 compiler automatically calculates the initial setting of SP without the programmer's concern.

Question 9: What does stack mean? A stack in computer science is a linear table limited to insertion or deletion operations only at the end of the table. Stack is a data structure that is a special linear table that can only be inserted and deleted at one end. It stores data according to the principle of last-in-first-out, the data that enters first is pressed into the bottom of the stack, the last data is at the top of the stack, and when data needs to be read it is popped out from the top of the stack (the last data is read out first). A stack is a special linear table that allows insertion and deletion operations at the same end. Allow insertion and deletion operations at one end is called the top of the stack (top), the other end for the bottom of the stack (bottom); the bottom of the stack is fixed, while the top of the stack floating; the number of elements in the stack is zero is called the empty stack. Insertion is generally called into the stack (PUSH), deletion is called out of the stack (POP). Stack is also known as the last in first out table (LIFO - Last IN First Out table Gong.). Stacks can be used to store breakpoints during function calls and are used when doing recursion!

The above is clear

Although it is copied

Question 10: What are the characteristics of the stack? A stack is a data structure that performs a "last in, first out" algorithm

A stack is such a data structure. It is an area of memory into which data is sequentially deposited (i.e., "pressed in - pushed out") one by one. There is an address pointer that always points to the data cell where the last data pressed into the stack is located, and the register that holds this address pointer is called the stack indicator. The cell where the data is first placed is called the "bottom of the stack". Data is deposited one by one, this process is called "pressing the stack". In the process of pressing the stack, every time a data is pressed into the stack, it is placed in the back of a unit connected to the previous unit, and the address in the stack indicator is automatically increased by 1. When reading these data, the data is read in accordance with the address in the stack indicator, and the number of addresses in the stack indicator is automatically decreased by 1. This process is called a "pop-up pop". This process is called "popping pops". This realizes the principle of last-in-first-out.