Determining the location of Top Of Stack
I am t开发者_高级运维rying 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,
- The list is empty
- The list is full
- The list is neither empty and not full Please help me out.
Thanks.
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.
精彩评论