0% found this document useful (0 votes)
20 views

Stack (Abstract Data Type) : For The Use of The Term LIFO in Accounting, See

A stack is an abstract data type that serves as a collection of elements, with two principal operations: push adds an element to the collection, and pop removes the last element added. The term LIFO refers to the fact that the last element pushed is the first one popped. Stacks have various software and hardware implementations and applications such as expression evaluation, backtracking, and memory management.

Uploaded by

elasu85
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Stack (Abstract Data Type) : For The Use of The Term LIFO in Accounting, See

A stack is an abstract data type that serves as a collection of elements, with two principal operations: push adds an element to the collection, and pop removes the last element added. The term LIFO refers to the fact that the last element pushed is the first one popped. Stacks have various software and hardware implementations and applications such as expression evaluation, backtracking, and memory management.

Uploaded by

elasu85
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Stack (abstract data type)

From Wikipedia, the free encyclopedia

For the use of the term LIFO in accounting, see LIFO (accounting).

This article includes a list of references, but its sources remain unclear because it
has insufficient inline citations. Please help to improve this article
byintroducing more precise citations. (September 2009)

Simple representation of a stack

In computer science, a stack or LIFO (last in, first out) is an abstract data type that serves as
a collection of elements, with two principal operations:[1]

push adds an element to the collection;

pop removes the last element that was added.

The term LIFO stems from the fact that, using these operations, the last element "popped off" a
stack in series of pushes and pops is the first element that was pushed in the sequence. This is
equivalent to the requirement that, considered as a linear data structure, or more abstractly a
sequential collection, the push and pop operations occur only at one end of the structure, referred to
as the top of the stack. (Additionally, a peek operation may give access to the top.)
A stack may be implemented to have a bounded capacity. If the stack is full and does not contain
enough space to accept an entity to be pushed, the stack is then considered to be in
an overflow state. The pop operation removes an item from the top of the stack. A pop either reveals
previously concealed items or results in an empty stack, but, if the stack is empty, it goes into
underflow state, which means no items are present in stack to be removed.
A stack is a restricted data structure, because only a small number of operations are performed on it.
The nature of the pop and push operations also means that stack elements have a natural order.
Elements are removed from the stack in the reverse order to the order of their addition. Therefore,
the lower elements are those that have been on the stack the longest. [2]
Contents
[hide]

1 History

2 Non-essential operations

3 Software stacks
3.1 Implementation

3.1.1 Array

3.1.2 Linked list


3.2 Stacks and programming languages

4 Hardware stacks
o

4.1 Basic architecture of a stack

4.2 Hardware support

4.2.1 Stack in main memory

4.2.2 Stack in registers or dedicated memory


5 Applications

5.1 Expression evaluation and syntax parsing

5.2 Backtracking

5.3 Runtime memory management

6 Security

7 See also

8 References

9 Further reading

10 External links

You might also like