edited by
3,737 views

2 Answers

2 votes
2 votes

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/

 

 

1 votes
1 votes
Option C :

Inserting element : Insert at last O(1),

Removing element : Delete from first (O(1) + O(n)[shifting n elements 1 step ahead]) = O(n).
Answer:

Related questions

1 votes
1 votes
2 answers
1
admin asked Apr 1, 2020
699 views
Which of the following is useful in traversing a given graph by breadth first search?StackSetListQueue
2 votes
2 votes
1 answer
2
admin asked Apr 1, 2020
1,058 views
The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number number of nodes in a binary tree of height $h$ is $2^{h}$$2^{h-1} ...
2 votes
2 votes
2 answers
3
admin asked Apr 1, 2020
1,022 views
The number of possible binary trees with $4$ nodes is$12$$13$$14$$15$
0 votes
0 votes
0 answers
4
admin asked Apr 1, 2020
264 views
At $100\%$ modulation, the power in each sideband is _______ of that of carrier.$50\%$$40\%$$60\%$$25\%$