user379888
user379888

Reputation:

Determining the location of Top Of Stack

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

Answers (1)

A.H.
A.H.

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

Related Questions