Was wondering how this can be done using C++.
Divide given array into 3 parts - (0 - N/3), (N/3 - 2N/3) , (2N/3 - N). How would i keep track of the overflow?
Thanks Kelly
Was wondering how this can be done using C++.
Divide given array into 3 parts - (0 - N/3), (N/3 - 2N/3) , (2N/3 - N). How would i keep track of the overflow?
Thanks Kelly
You must necessarily maintain a pointer-to-top for each of your stacks. Why not just check that these pointers don't exceed their bounds?
void push(int stacknum, T data) { if (top[stacknum] == (N/3)*stacknum) { error("overflow"); } else { /* Push */ } }.for (i = 0; i < 3; i++) { arrayPointer[i] = &buffer[sizeofStack*i]; }. Indices would be: int arrayIndices[3]; for (i = 0; i < 3; i++) { arrayIndices[i] = sizeofStack[i]; }.