void reverseQueue(queue<int>& Queue)
{
stack<int> Stack;
while (!Queue.empty())
{
Stack.push(Queue.front());
Queue.pop();
}
while (!Stack.empty())
{
Queue.push(Stack.top());
Stack.pop();
}
}
I was wondering what the Big-O or Big-Theta notation of this function would be, if we called it with a Queue of n elements. Would it be something along the lines of O(n^2), since we're pushing and popping n elements twice in order to move it from the stack back to the queue in a reversed order? Thank you for any help.