Heap pile stack

Pamela fluente


I am not clear what is the difference between terms such as heap, pile, stack. I understand that they have some specialized meaning in computer science, but it's harder to figure out the nuances you associate with each of them. For instance if I have a column of numbers would that be also a stack of numbers, or a pile or what else ? :)

  • Hockey13

    Senior Member
    A stack of something is when its component parts are neatly thrown on top of one another. You can have a stack of wood if you've spent time making it stand up well.

    A pile of something is usually just created from randomly throwing things on top of one another. A pile of wood is when you just throw a lot of wood on a spot and don't care how nice it looks.

    I usually use "heap" in reference to something bunched up in a corner or something like that. A heap of clothes can be dirty laundry that is piled up in the corner after being thrown there. A person can also be on the ground in a heap after being beaten up.


    Senior Member
    Southern AE greatly modified by a 1st-generation Scottish-American mother, and growing up abroad.
    Generalizations about these strange worlds don't always hold up. Stacks tend to be orderly, and they tend to be higher than heaps or piles-- which are both disordered, but heaps tend to be a little larger than piles.

    All of these words can refer to mounded-up materials, but usually only stacks and piles can be structured.

    The really troublesome fact, for beginning learners, is that some inflexible idiomatic usage is involved, much of it involving the material which is piled, stacked-- or just lying there, accumulating in a heap.

    For example, you find hay in a haystack, whether the stuff is just piled up loose-- or baled and stacked, in a perfect bricklike pattern.

    Wood, on the other hand, is said to be in a pile, whether it is cut in lengths and thrown in a sort of loose pyramid-- or stacked up like haybales or bricks, in those orderly woodpiles you see when you drive through rural Germany or Switzerland.

    You can have a pile of garbage, but the place where a lot of garbage is dumped tends to be called a garbage heap.

    Dirt is piled, which I guess means that compost heaps turn into dirtpiles eventually.

    Sometimes permanent structures are called stacks, such as brick chimneys (smokestacks) and library shelves that hold archived material (the stacks).

    Heaps and piles are much the same thing in general, though-- both words apply equally to a quantity of laundry or trash or rubbish.

    Sometimes flat things are stacked and more compact shapes are piled-- you'd never call a brickpile a stack, but you might have papers or folders stacked up on your desk. If they form towers, they are stacks-- if they are just dumped there, they are in a pile.

    Paperwork that is piled up, in urgent need of attention, can also be said to be stacked up." But anything waiting in line, like people in a waiting room or an audience lined up out on the sidewalk waiting to buy tickets, or airplanes circling the airport waiting to land-- are said to be stacked up. Never piled up-- that implies too much disorder, and the passengers might get a little panicky.

    The problem with these words is that the differences in usage are so subtle, but in many cases it makes a heap of difference which you use.

    I would advise beginners to memorise these usage differences on a case-by-case basis. No reliable rule is available

    Pamela fluente

    By the way. How could I call properly something that is similar to a "stack" of numbers, but grows adding new elements at its bottom ? Like a column of figures, where the new ones are added below...

    -> 34 (recent)
    -> 12 (last added)



    USA English
    There is not much of a difference and for the most part you could use them interchangeably. But I think of a pile as sometimes a little neater or more organized, while a heap is a bunch of stuff just thrown together. You could have a pile of folded laundry, but you would expect a heap of laundry to be the dirty stuff thrown on the bathroom floor.


    New Member
    India - Hindi & English
    In technology, stack is used for static memory allocation and Heap for dynamic memory allocation, both stored in the computer's RAM .

    Variables allocated on the stack are stored directly to the memory and access to this memory is very fast, and it's allocation is dealt with when the program is compiled. When a function or a method calls another function which in turns calls another function etc., the execution of all those functions remains suspended until the very last function returns its value. The stack is always reserved in a LIFO order, the most recently reserved block is always the next block to be freed. This makes it really simple to keep track of the stack, freeing a block from the stack is nothing more than adjusting one pointer.

    Variables allocated on the heap have their memory allocated at run time and accessing this memory is a bit slower, but the heap size is only limited by the size of virtual memory . Element of the heap have no dependencies with each other and can always be accessed randomly at any time. You can allocate a block at any time and free it at any time. This makes it much more complex to keep track of which parts of the heap are allocated or free at any given time.
    < Previous | Next >