function POP( top, N)
{
if (X)
{
top = top - 1
}
else
{
print "Underflow"
}
return top
}
Answers
Answered by
0
Answer:
Mark me brilliantest pls I can't believe
Answered by
7
Stack is the most used data structures in CPP. It follows Last in First Out and First in Last out approach.
if top >= 0 this condition can be used for popping an element from the stack.
Explanation:
- In stack the top is used for insertion and deletion of elements in Stack.
- Stacks are a type of container that follows the LIFO order that is (Last In First Out) type of work.
- every new element is added at one end called the top of the stack.
- And also an element is removed from the same end only.
- top() function is used to reference and address the top that is the newest element of the stack.
- One should ensure that there are one or more elements on the stack before calling the top function, it should not be empty.
Similar questions