NTA UGC NET JUNE-2023 Paper-2
October 29, 2023
UGC NET CS 2015 Dec- paper-2
October 29, 2023
NTA UGC NET JUNE-2023 Paper-2
October 29, 2023
UGC NET CS 2015 Dec- paper-2
October 29, 2023

Question 9491 – GATE 2004

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 top2 (topl < top2) 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

Correct Answer: D

Question 3 Explanation: 
Since the stacks are growing from opposite ends, so initially top1=1 and top2=Max_size. Now to make the efficient use of space we should allow one stack to use the maximum possible space as long as other stack doesn’t need it. So any of the stack can grow towards each other until there is space available in the array. Hence, the condition must be top1 = top2 – 1.
A
(top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
B
top1 + top2 = MAXSIZE
C
(top1 = MAXSIZE/2) or (top2 = MAXSIZE)
D
top1 = top2 – 1
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!