+ 2
What is that where deque is the life saver
Hi All When we have requirement to access values randomly rather than iterating one by one, vector is the best option.. For operation like sequences in original order it was provided , queue helps us... Example is processing instructions in provided order. When we just want to reverse something , stack is handy. Example is to reverse the string.. Is above true? Query is about deque. What is it's use case? Opting other than deque will be costlier in which case ?
5 Antworten
+ 4
As far as I know,there is no special case where a deque is preferable.In all scenarios there is always a container that outperforms a deque
+ 3
A deque is a doubly-ended queue,meaning that unlike a queue you can access(read and write) both of its ends.
For its use case,well,it might come as a surprise to many,but queues and stacks use deques as their underlying container.
However I don't actually recommend using it as a container since there is always a better alternative in all given scenarios.Its better to just leave it as an implementation detail of the two above classes.
0
Yes a surprise Anthony Maina ...I thought array or linked list as implementation for queue and stack...
I understand what we can do on deque but looking for some use case.. is it just for implementing queue and stack ? It's difficult to digest as if so, that might not be available to us as seperate entity
0
Okay Anthony Maina