codeintuition-logo

Determining the size of the stack


The size operation tells the caller about the current size of the stack. Since topIndex is the index of the last item inserted in the stack, topIndex + 1 is the current size of the stack.

Loading Image

Size of a stack can be calculated using the topIndex

Algorithm

Liking the course? Check our discounted plans to continue learning.