Stacks and Queues

danhodge

In Runtime
Messages
324
Location
UK
Hi,
So I'm doing computer science, and we've moved onto data structures, and for some reason i'm having a difficult time getting my head around some concepts. Mainly, Stacks and Queues.

My confusion is that I don't understand exactly what they are (specific, I know). Like, in terms of a Stack, from its properties and its function I'd assume its just another Collection, like an Array, but I feel like I'm missing something. I decided to Google this, and look over lecture notes, and i've just been left more confused. I'm seeing people use stacks in arrays or something like that and i'm starting to wonder what I'm missing :neutral:

To clarify, I know about the properties of a Stack (FILO for example), and I know that they can be used as a collection, but is it as simple as "Do i use a Stack or an Array"?

Thanks a lot for baring with me on my most confusing question yet,
Danny
 
Stacks and Queues are arrays. They're just different implementations of arrays (or Lists/vectors, depending on your language / implementation).

Stacks / queues use "push" and "pop" operations.

Whether your use a stack / queue / or normal array/list...all depends on what you're doing. If you're wanting to keep track of specific order and only push/pop in the order of a stack/queue...then those are best. I'd say 90% of the time you're just use a normal array or list, however.
 
Back
Top Bottom