Data structure:
Stack is a special linear table that allows insertion and deletion at the same end. One end that allows the insert and delete operations is called the top, and the other end is the bottom of the stack. The bottom of the stack is fixed, while the top of the stack is floating; when the number of elements in the stack is zero, it is called an empty stack. Insert is generally called push and delete is called pop ). Stack is also known as a forward, forward, and forward table.
Operating System:
The compiler automatically assigns release, stores function parameter values, and local variable values. The operation method is similar to the stack in the data structure.
The stack uses a level-1 cache, which is usually in a bucket When called, and is immediately released after the call is completed.
Stack chain template code:
# Define true 1 # define false 0 typedef struct node {stackelementtype data; struct node * Next;} linkstacknode; typedef linkstacknode * linkstack;/* stack operations. */INT push (linkstack top, stackelementtype X)/* press Data Element x into the top stack */{linkstacknode * temp; temp = (linkstacknode *) malloc (sizeof (linkstacknode); If (temp = NULL) Return (false);/* space application failed */temp-> DATA = X; temp-> next = Top-> next; top-> next = temp;/* modify the top pointer of the current stack */Return (true);}/* stack operation. */Int pop (linkstack top, stackelementtype * X) {/* pop up the top element of the stack, and place it in the bucket X. */linkstacknode * temp; temp = Top-> next; If (temp = NULL)/* stack is empty */Return (false); top-> next = temp-> next; * x = temp-> data; free (temp);/* release the bucket */Return (true );}
Stack operation-stack chain