|
Notes > Models of Computation > Stacks and Queues
|
Stacks
Stacks are a "last in, first out" (LIFO) structure. All stacks can have items added to the top of them (pushed) and removed (popped) from the top of them also. This means that any item you are removing will be the last item that was added. Real life examples such as a stack of boxes or chairs helps to illustrate the point.
Depending on its implementation a stack may be "ascending" or "descending" where the lowest address is at the top of the stack. It may also be "full" if the stack pointer points to the top of the stack or "empty" if the stack pointer points above the top of stack.
Because of the structure of a stack the only way you can remove the bottom element is by removing all the elements above it first. An error will occur are raised by attempts to pop an empty stack or to push an item onto a stack which has no room for further items (because of its implementation)
Queues
Queues are a "first in, first out" (FIFO) data structure. Objects are taken off the head of the queue and added to the tail of it.
Search for "Stacks and Queues" on:
Google |
Kelkoo |
Amazon |
eBay (UK) |
eBay (US)
Search for "Stacks and Queues" on the rest of Computing Students: Stacks and Queues
|
|
|