-
A single array A [1...MAXSIZE] is used to implement two stacks. The two stack graw from opposite ends of the array. Variable top 1 and top 2 (top 1 < top 2) point to the location of the topmost element in the each of the stacks. If the space is to be used efficiently, the condition for stack full is
-
- (top1 – MAXSIZE/ 2) and (top 2 = MAXSIZE/2 + 1)
- top1 + top 2 = MAXSIZE
- (top1 = MAZSIZE/2) or (top 2 = MAXSIZE)
- top1 = top 2 – 1
- (top1 – MAXSIZE/ 2) and (top 2 = MAXSIZE/2 + 1)
Correct Option: D
Let take MAXSIZE =10
Here the stack will be fuel if both top 1 & top 2 are at the adjacent index values i.e., their difference is 1.
So top 1 = top 2 – 1
Here (d) is correct option.