110 likes | 315 Views
Stacks. Using arrays... Can populate an array with information... Then remove it as we deal with it. Stacks. Uses FILO First in Last out. Stacks. Stacks. Examples... Back button on a browser: Undo facility Call back... Do anything in reverse order. Operations .
E N D
Stacks • Using arrays... • Can populate an array with information... • Then remove it as we deal with it...
Stacks • Uses FILO • First in Last out
Stacks • Examples... • Back button on a browser: • Undo facility • Call back... • Do anything in reverse order...
Operations • Create a new stack object • Delete a stack object • Push an element on to a stack • Pop an element from a stack • Peek the value of the top element, leaving the stack unchanged • isEmpty to check if the stack is currently empty • isFull to check if the stack is currently full • currentSize a useful operation to report how many items present
Stacks • Create using an Array • When count = 10 the array is full
Implement a Stack? • Will need: • Array • Keep track of the top... • Add values... • Remove values...
Summary • Stacks • What are they?