Sunday 24 June 2012

Deque

Deque is Double Ended Queue: items can be added/removed from the either end of the queue.


Operations:


Insertion to the front (push_front):

- Algorithm: item is added at the front of the queue
- Complexity: O(1)


Insertion to the back (push_back):

- Algorithm: item is added at the  back  of the queue
- Complexity: O(1)


Peek at the front:

- Algorithm: return a value of the item from the front of the queue
- Complexity: O(1)


Peek at the back:

- Algorithm: return a value of the item from the back of the queue
- Complexity: O(1)



Removal from the front (pop_front):

- Algorithm: remove the item from the front of the queue
- Complexity: O(1)



Removal from the end (pop_back):

- Algorithm: remove the item from the  back of the queue
- Complexity: O(1)

No comments:

Post a Comment