Kelly
Kelly

Reputation: 213

Implementing 3 stacks in one Array using C++

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

Upvotes: 0

Views: 643

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272802

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?

Upvotes: 1

Related Questions