edited by
35,120 views
48 votes
48 votes

A single array $A[1 \ldots \text{MAXSIZE}]$ is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables $top1$ and $top2$ $(top1 < 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 $\text{“}\textsf{stack full}\text{”}$ is

  1. $(top1 = \text{MAXSIZE} / 2)$ and $(top2 = \text{MAXSIZE} / 2 + 1)$

  2. $top1 + top2 = \text{MAXSIZE}$

  3. $(top1 = \text{MAXSIZE} / 2)$ or $(top2 = \text{MAXSIZE})$

  4. $top1 = top2 - 1$

edited by

6 Answers

–3 votes
–3 votes
I think both A and D are correct.actually both defining same thing.
–4 votes
–4 votes
A ) top1= ⎣MAXSIZE/2⎦

     top2= ⎣MAXSIZE/2⎦+1
Answer:

Related questions

19 votes
19 votes
4 answers
1
Kathleen asked Sep 18, 2014
6,945 views
The best data structure to check whether an arithmetic expression has balanced parentheses is aqueuestacktreelist
27 votes
27 votes
3 answers
2
Kathleen asked Sep 18, 2014
5,595 views
The elements $32, 15, 20, 30, 12, 25, 16,$ are inserted one by one in the given order into a maxHeap. The resultant maxHeap is
19 votes
19 votes
3 answers
4
Kathleen asked Sep 18, 2014
6,388 views
Level order traversal of a rooted tree can be done by starting from the root and performingpreorder traversalin-order traversaldepth first searchbreadth first search