Consider the following stack operation along with push and pop instructions which sort the stack ‘a’ using temporary stack ‘temp’.

while (!a.empty())

    {

        int x = a.top();

        a.pop();

        while (!temp.empty() && temp.top() > x)

        {

           a.push(temp.top());

            temp.pop();

        }

        temp.push(x);

    }

Calculate the total number of pop operations performed to sort the stack of integers 27 12 20 33 16.(16 is the top element on a stack)

Enter numerical value using the virtual keypad. Round off where necessary.

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation