A stack is implemented with an array of ‘A [0..N – 1]’ and a variable ‘pos’. The push and pop operations are defined by the following code.

push(x)

                A[pos] ← x

                pos ← pos – 1

end push

pop( )

                pos ← pos + 1

                return A[pos]

end pop

Which of the following will initialize an empty stack with capacity N for the above implementation?

1
pos ← -1
2
pos ← 0
3
pos ← 1
4
pos ← N - 1

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation