Dark Mode

1,241 views

1 vote

You don't need to traverse the entire list to find the new tail, you just need to add a new node where the current tail points to and set that node as the new tail.

From which we can conclude that the time complexity is O(1).

For dequeing, we only need to set the next node of the current head as the new head and return the value of the old head.

From which we can conclude that the time complexity is O(1).

Time complexity of all operations like enqueue(), dequeue(), isFull(), isEmpty(), front() and rear() is O(1). There is no loop in any of the operations.

https://www.geeksforgeeks.org/queue-set-1introduction-and-array-implementation/