80.0k views
4 votes
The complexity of an enqueue operation with a single linked queue implementation is:

a. 0(1)
b. O(n)
c. O(2n)
d. O(1) usually, but order O(n) in the worst case when the collection has to be copied and expanded

1 Answer

3 votes

Final answer:

The complexity of an enqueue operation with a single linked queue is usually O(1), but can be O(n) in the worst case.

Step-by-step explanation:

The complexity of an enqueue operation with a single linked queue implementation is O(1) usually. However, it can be O(n) in the worst case when the collection has to be copied and expanded. In the usual case, enqueueing an item to a single linked queue takes constant time because it involves only updating the tail pointer of the queue to point to the new item. This operation does not depend on the size of the queue, so it has a constant time complexity, denoted as O(1).

User Enricog
by
7.8k points