Stacking vs. Queuing: efficiency

109 Views Asked by At

From an efficiency stand point, which would be better: Stacking or Queuing? And perhaps Heaping? I've been doing a lot of research and tried a few of my own things, it seems Heaping is worse than both Stacking and Queuing. But when I was testing Stacking and Queuing, they were similar in speed. I tried finding the answer, but no answer was reached.

1

There are 1 best solutions below

0
On

The question is meaningless without an application. If you want to process things in a first-in, first-out manner, you use a queue. If you want to process things first-in, last-out, you use a stack. If you want to process things by priority, you use a heap or some other priority queue implementation.

The question isn't "which is better, stack, queue, or heap?" The question is, "what is the most appropriate data structure for the problem I'm trying to solve?"