On Mon, Nov 11, 2002 at 11:43:10PM -0500, Russell Hires wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> This is my problem that I come across for most sites:
>
> STACK
> "Definition: A collection of items in which only the most recently added item
> may be removed. The latest added item is at the top. Basic operations are
> push and pop. Also known as "last-in, first-out" or LIFO. "
>
> And my response: "Okay, great! What do you use it for?" or "So what?" This
> simply says what a stack is, but nothing more. What would you push or pop?
> And why would you? The only "data structure" that I get is the queue, and
> only in one context: mouse clicks. You point and click on several items in a
> sequence, and the queue processes them in the order that you clicked them.
>
This is kinda like showing you a picture of something and telling you
it's a wrench. But without any further experience, it's not clear at all
what a wrench is _for_, or why you should use one instead of your
pliers (which look like they kinda do the same thing).
A queue is kind of the reverse of a stack, because it's
first-in-first-out, where a stack is last-in-first-out. Jason's
example was a good one for a stack. Personally, I've never found the
need to use a stack in a program. I know what they are, and I could
probably code one from scratch if I needed to, but I just haven't found
the need. A lot of data structures are that way-- worth knowing about,
but you may never use them. But then the day comes where you're coding
and you think, "I need something for this job... what would do this? A
stack!"
Paul
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:42:03 EDT