-->
当前位置:首页 > 题库

单选题:Following is the C-like pseudo code of a function that takes a Q

Luz5年前 (2021-05-10)题库1764
Following is the C-like pseudo code of a function that takes a Queue as an argument.
```
void foo(Queue Q)
{
Stack S = CreateStack(); // create an empty stack

while (!IsEmpty(Q))
{
// dequeue an item from Q and push it into S
Push(S, Dequeue(Q));
}

while (!IsEmpty(S))
{
// pop an item from S and enqueue it into Q
Enqueue(Q, Pop(S));
}

DisposeStack(S);
}
```
What does the above function do? @[D](2)

A. Removes the last item from Q
B. Keeps Q unchanged
C. Makes Q empty
D. Reverses Q




A.Removes the last item from Q
B.Keeps Q unchanged
C.Makes Q empty
D.Reverses Q


答案:D