Stacks: Ref.: D.S. Malik, Data Structures Using C++
Stacks: Ref.: D.S. Malik, Data Structures Using C++
Stacks
a stack
an empty stack
Stacks
push adding an item to the top of a stack peek looking at the item on the top pop removing an item from the top of a stack
Useful operations
Initialise Stack makes the stack an empty stack Is Stack Empty? checks to see whether stackTop = 0 Is Stack Full? - checks to see whether stackTop = maxStackSize
Useful operations
Push if stack is not full then {add an item to position [stackTop] increment stackTop} Peek if stack is not empty then output item at [stackTop] Pop if stack is not empty then decrement stackTop
Useful operations
Is Stack Empty? Check to see if stackTop = NULL Is Stack Full? Do not need this operation
D stackTop
newNode
Useful operations
Peek if stack is not empty then return stackTop->info