954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

diffirence between stack and queu

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 ;)

amir808
Newbie Poster
8 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

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

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 
A stack is: last in / first out A queue is: first in / first out

so thats the only difference? thnx:D

amir808
Newbie Poster
8 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

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.

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

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.

WaltP
Posting Sage w/ dash of thyme
Moderator
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 
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 ;)

amir808
Newbie Poster
8 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

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...

amir808
Newbie Poster
8 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You