1 / 9

Stacks

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 .

brasen
Download Presentation

Stacks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Stacks • Using arrays... • Can populate an array with information... • Then remove it as we deal with it...

  2. Stacks • Uses FILO • First in Last out

  3. Stacks

  4. Stacks • Examples... • Back button on a browser: • Undo facility • Call back... • Do anything in reverse order...

  5. 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

  6. Try the stack sheet...

  7. Stacks • Create using an Array • When count = 10 the array is full

  8. Implement a Stack? • Will need: • Array • Keep track of the top... • Add values... • Remove values...

  9. Summary • Stacks • What are they?

More Related