Home >  Term: stack
stack

A collection of items in which only the most recently added item may be removed. The latest added item is at the top. Basic operations are push and pop. Often top and isEmpty are available, too. Also known as "last-in, first-out" or LIFO. Formal Definition: The operations new(), push(v, S), top(S), and popoff(S) may be defined with axiomatic semantics as follows.

  1. new() returns a stack
  2. popoff(push(v, S)) = S
  3. top(push(v, S)) = v
where S is a stack and v is a value. The pop operation is a combination of top, to return the top value, and popoff, to remove the top value.

0 0

Looja

  • GeorgeV
  •  (Gold) 1123 points
  • 100% positive feedback
© 2024 CSOFT International, Ltd.