1
这是我遇到的一个竞争性测验问题。我对所提供的答案并不满意。2个堆栈在单个阵列内存中效率
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< 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
(a) (top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
(b) top1 + top2 = MAXSIZE
(c) (top1 = MAXSIZE/2) or (top2 = MAXSIZE)
(d) top1 = top2 -1
我的逻辑是在两端开始,因此,我的答案(二)但是测验标志着答案(d)为正确去了。我错过了什么?
谢谢。
精确到点。谢谢。 – 2014-09-19 20:40:57