language agnostic - Stack data storage order -


While talking about a stack in either computing or "real" life, we usually call a "first, last stop "Kind regards functionality.

Because the idea of ​​stack is around some things in the physical world, does it make any difference to how stack data is stored?

I have seen in many instances that stack data is often stored using an array and the latest item added to the stack is placed below the array. (Such as adding the existing stack of plates to a new plate, it is placed below other plates instead of above).

As a paradigm, is it the figure how the data is stored inside the stack, until the operation of the stack works as expected?

It does not matter how your data stores in memory until the functionality and are expected as functionality.

Often the heap is implemented as an array with a size and capacity where the size is currently the maximum number of stacks and capacities that can be stored without the need for any relatively expensive real-realization. .

Refined o (1) ability to give performance is usually doubles. Applying the stack with the empty space at the end of the high index end of the array is usually easy, so it is usually done.

To give a specific example, the current top of the stack was stored as an index in the array of the top element if the items were added down to the highest index of the array, then when the array made more space for more elements If there is increase, then the index of the array's top index will also change. When filling the index of the top element can not change when the array has to be resized.

If you want to apply your stack differently, you can ensure that performance and performance documents of your implementation are documented.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -