Reputation:
I am trying to create an array based implementation of Stacks. I am a bit confused with where should the Top Of Stack
(a variable in my implementation) be when,
Thanks.
Upvotes: 0
Views: 230
Reputation: 66273
That depends only how you define TopOfStack
: is it the first unused slot? Or is it the last thing pushed onto the stack.
As soon as you choose one of those two options the rest can be deduced easily.
Upvotes: 1