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

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

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

while (!IsEmpty(Q))
{
// dequeue an item from Q and enqueue it into Q1
Enqueue(Q1, Dequeue(Q));
}

while (!IsEmpty(Q1))
{
// dequeue an item from Q1 and enqueue it into Q
Enqueue(Q, Dequeue(Q1));
}

DisposeQueue(Q1);
}
```
What does the above function do? @[B](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


答案:B