can a stack act as a queu or does it has to be last in first out?
i am trying to make a program, using Huffman`s compression theory, and i am using stack, while its explained using a queu...i want to know if this can be done...
thanks in advance ;)

A stack is: last in / first out
A queue is: first in / first out

so thats the only difference? thnx:D

The purpose of the queue is to ensure the elements are given treatment in the order they were received.

The intended purpose is really the difference.

In actuality, you can do anything you want with either given enough memory and a proper algorithm.

...but I'm sure that's outside of the spirit and intention of your question.

There's one other structure that is available -- a dequeue (pronounced DECK).
Items can be added and removed from either end. This may be what you need.

There's one other structure that is available -- a dequeue (pronounced DECK).
Items can be added and removed from either end. This may be what you need.

okay thanks!...i`m gonna try that ;)

The purpose of the queue is to ensure the elements are given treatment in the order they were received.

The intended purpose is really the difference.

In actuality, you can do anything you want with either given enough memory and a proper algorithm.

...but I'm sure that's outside of the spirit and intention of your question.

hehe no its good enough...

This question has already been answered. Start a new discussion instead.