I'm writing a sort algorithm where I can only use stacks. By increasing the amount of stacks, I can do the sort with less operations.
Anyway, say I have a dataset of 10 integers. What would be the difference in memory for the following (with std::stack
):
- an array of stacks of size 2 (5 integers per stack)
- an array of size 10 (1 integer per stack)
- an array of size 20 (1 integer each in 10 stacks, 10 stacks are empty)
Also, how much memory does an empty stack of int take? Would it just be an extra int pointer?
Please treat this question as an academic one. I know there are better ways of solving this problem, but I can only use stacks.