edited by
36,001 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

7.2k
views
4 answers
19 votes
Kathleen asked Sep 18, 2014
7,156 views
The best data structure to check whether an arithmetic expression has balanced parentheses is aqueuestacktreelist
5.8k
views
3 answers
27 votes
Kathleen asked Sep 18, 2014
5,788 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
10.0k
views
5 answers
24 votes
Kathleen asked Sep 18, 2014
10,030 views
Given the following input $(4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199)$ and the hash function $x$ mod $10$, which of the following statements are true?$9679, 1989, 4...
6.6k
views
3 answers
19 votes
Kathleen asked Sep 18, 2014
6,616 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