Stack and heap have completely different properties and customs.
The stack is necessary for LIFO. Sorting will cost O (N * logN), Push / pop O (1).
A heap is needed for the priority queue, for example, to get the min / max element it will cost O (1), inserting the O (log (N)) element
You need to define a usage pattern and purpose, and then decide what exactly you need.
source
share