Data structure - linear form - Stack

Stack 
    linear form having a certain operational constraints: inserting only made at one end (top of the stack, Top), delete the 
        inserted data: push (Push)  
        delete the data: the stack (Pop)  
        First-Out: Last In First Out ( LIFO) 
    
stack abstract data types: 
    type name: stack (stack) 
 
    set of data objects: a 0 or a plurality of finite elements of linear form. 
 
    The set of operations: length MaxSize stack S  Stack, stack elements Item  the ElementType
         . 1, Stack CreateStack ( int MaxSize): generating empty stack, with a maximum length MaxSize; 
         2, int IsFull (Stack S, int MaxSize): Analyzing Stack S is full; 
         . 3, void the Push (stack S, the ElementType item): the item element onto the stack; 
         . 4, int the IsEmpty (stack S): S is determined whether the stack is empty; 
         . 5 , the ElementType Pop (stack S): delete and returns the top element;
    
Sequentially storing stack implemented: 
    sequential storage structure stack typically consists of a one-dimensional array variables and a top element position of the record. 

Chain store implementation stack: 
    the stack of linked storage structure is actually a single chain, called chain stack. Only insertion and deletion operations in the link stack stack     
    
applications:
     1 . How to convert infix expressions postfix 
        read from top to infix expressions for each object, for processing different objects in different situations. 
        ① operand: direct output; 
        ② left parenthesis: onto the stack; 
        ③ right parenthesis: the top of the stack and pop operators output, until it encounters the left bracket (the stack is not output); 
        ④ operator: 
            • If priority when the operator is greater than the top of the stack, push it put; 
            • when priority less than equal to the stack operator, the operator stack and pop outputs; top of the stack and then compare the new operator, the operator until the stack is greater than Until operator precedence, and the operator then pushed onto the stack;      
        ⑤ if each object is processed, put the remaining stack operator output together. 
    
    2 . Recursive function calls and
     3 . Depth-first search 
    . . .
    
    

 

Guess you like

Origin www.cnblogs.com/liuxuelin/p/11922242.html