O'Reilly logo

Learning Functional Data Structures and Algorithms by Raju Kumar Mishra, Atul Khot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summary

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 pushFront, popFront, pushBack, and 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required