Ch3-1-Stack - DataStructureStack SangYongHan...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Data Structure - Stack                 Sang Yong Han            http://ec.cse.cau.ac.kr/ Chung-Ang University Spring 2011 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Stacks Stack: what is it? ADT Applications Implementation(s) Tower of Hanoi Maze (Maze Routing) Mathematical Expression
Background image of page 2
What is a stack? Stores a set of elements in a particular order Stack principle:  LAST  IN  FIRST  OUT LIFO It means: the last element inserted is the first one to  be removed Example Which is the first element to pick up?
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Last In First Out B A D C B A C B A D C B A E D C B A top top top top top A
Background image of page 4
Stack  Applications Real life Pile of books Plate trays More applications related to computer science Program execution stack (read more from your text) Evaluating expressions
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Method Invocation And Return public   void  a() { …; b(); …} public   void  b() { …; c(); …} public   void  c() { …; d(); …} public   void  d() { …; e(); …} public   void  e() { …; c(); …} return address in a() return address in b() return address in c() return address in d() return address in e() return address in c() return address in d()
Background image of page 6
  objects:  a finite ordered list with zero or more elements.    methods:     for all  stack     Stack ,  item     element max_stack_size         positive integer     Stack  createS( max_stack_size ) ::=                create an empty stack whose maximum size is                  max_stack_size     Boolean  isFull( stack, max_stack_size ) ::=                 if  (number of elements in  stack == max_stack_size )                return  TRUE                
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 33

Ch3-1-Stack - DataStructureStack SangYongHan...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online