stack is implemented as a linear array A[0…N-1]. Noor writes the following functions for popping an element from the stack.?
function POP(top,N)
{
if(X)
{
top=top-1;
}
else
{
print "Underflow"
}
return top;
}
What should be replaced in X ?
A) top< N-1
B) top< N
C) top>1
D) top>=0
Answer & Solution
Answer: Option DSolution:
top>=0 should be replaced in X for popping an element from the stack.