Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 4th, 2012  |  syntax: None  |  size: 0.65 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ADT Specifications Modification for Stacks
  2. TYPES
  3.  
  4. •   STACK[G]
  5.  
  6.  
  7. FUNCTIONS
  8. •   put: STACK[G] x G -> STACK[G]
  9. •   remove: STACK[G]-/> STACK[G]
  10. •   item: STACK[G] -/> G
  11. •   empty: STACK[G] -> BOOLEAN
  12. •   new: STACK[G]
  13. •   count: STACK[G] -> INTEGER
  14. •   change_top: STACK[G] x G -> STACK[G]
  15. •   wipe_out: STACK[G]
  16.  
  17.  
  18. AXIOMS
  19.  
  20. For any x:G, s:STACK[G]
  21.  
  22. •   A1 - item(put(s,x)) = x
  23. •   A2 - remove(put(s,x)) = s
  24. •   A3 - empty(new)
  25. •   A4 - not empty(put(s,x))
  26. •   A5 - count(new)
  27.  
  28.  
  29. PRECONDITIONS
  30.  
  31. •   remove(s:STACK[G]) require not empty(s)
  32. •   item (s:STACK[G]) require not empty(s)
  33. •   change_top (s:STACK[G]) require not empty(s)