InvestorsHub Logo
icon url

AIMster

09/22/03 11:55 AM

#9758 RE: The Grabber #9727

Hi, Steve,

I have no idea what a 'Stack' is. I've already asked the question out at Mr. Excel, and have received one reply already asking for more info. I'll see what comes of that.

A common analogy for understanding a stack and how it functions is to envision a stack of plates (as are often found at a local Chinese buffet). Each "plate" can hold a value. Assuming that one can remove plates from either the top or bottom without toppling over the whole lot picture this:

Diners come and take a plate to get their food from the top of the stack. These were the last to be placed on the stack from the clean dishes returned from the kitchen. Thus, they were the last on the stack and are now the first off (LIFO). The dishes remaining underneath "pop up" as the spring mechanism lifts the lot to move the next plate into position.

Similarly, if the stack is fed from the top down, a person would take a plate from the bottom of the stack. Since they are being replenished from the top, the first on the stack is now the first off (FIFO).

In both cases the length of the stack is decremented by 1 (plate removed) and then the last stored plate moves into position to be taken off the stack by the next customer. So a stack can grow dynamically as values are "pushed on" to the stack or "popped off" the stack. It is from which end of the stack that you add or remove "plates" that determines the FIFO or LIFO basis of the transaction. Substitute spreadsheet cells for example, or (in programming) a dynamic array - each position capable of holding a value and you'll get the idea.

Hope this helps.

Best,

Patrick