We looked at another common data structure called a deque. A deque is a double-ended queue, so insertions and deletions are possible at both ends. We looked at
popBack operations. We also looked at some applications of deques.
Deques have a simple implementation in the imperative world. A doubly linked list could be used for implementing it. A vector could be used too.
We looked at two important concepts: amortization and lazy evaluation. We took a detailed look at Scala's Streams. We saw what a thunk is and how it helps us with delayed evaluation.
We then used all these concepts to check whether we can create more efficient queues. As we saw in the previous chapter, reversing an
in list and appending it ...