GATE CS 2004 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0241

A single array A[1...MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top 2 (top1 \(\lt\) top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for "stack full" is
  1. A
    (top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
  2. B
    (top1 + top2 = MAXSIZE
  3. C
    (top1 = MAXSIZE/2) or (top2 = MAXSIZE)
  4. D
    top1 = top2 -1

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionOfficial GATE Answer Key: Option D.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/1000/gate2004-3

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com