Chapter 5 Stack
Chapter 5 Stack
5.1 definition of stack Definition a stack is a linear list in which insertions and deletions take place at the same end.This end is called the top. The other end of the list is called the bottom It is also called a lifo(last-in-first-out)list
5.1 definition of stack Definition : A stack is a linear list in which insertions and deletions take place at the same end.This end is called the top. The other end of the list is called the bottom. It is also called a LIFO(last-in-first-out) list
5.1 definition of stack Figure 5. 1 stack configurations E长top DK-top DCB B Btop A长 bottomA< bottom A长 bottom
5.1 definition of stack Figure 5.1 stack configurations Etop Dtop D C C B B Btop Abottom Abottom Abottom
5.2 ADT Stack AbstractData Type Stacki instances linear list of elements one end is called the bottom the other is the top operations Create: Create an empty stack; IsEmpty O: Return true if stack is empty, return false otherwise
5.2 ADT stack AbstractDataType Stack{ instances linear list of elements;one end is called the bottom;the other is the top; operations Create():Create an empty stack; IsEmpty():Return true if stack is empty,return false otherwise
5.2 ADT Stack IsFull o: Return true if stack if full, return false otherwise Top(: return top element of the stack; Add(x) add element x to the stack Delete(): Delete top element from stack and put it In X
5.2 ADT stack IsFull ():Return true if stack if full,return false otherwise; Top():return top element of the stack; Add(x): add element x to the stack; Delete(x):Delete top element from stack and put it in x; }