Well there is lot of discussion about implementing 3 [ or 2 stacks ] in a single array. but whats the real need or application for implementing stacks like that?
can't we allot memory as 3 seperate stacks [array] itself?. anyway we are alloting array[size * 3] in that single array.
intis a primitive data type that consume memory space of4 bytes, anobjectofclass { int, int, int }would consume3 * 4 = 12 bytes; the size of apointerinC\C++is4 bytes; in the case of integers, we have4 = 4so it's not difference .. but in case of objects (as the example) we have4 < 12thus it's more efficient to store 3 stacks of the same values using a single one