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 some more list algorithms in this chapter and how lists permeate functional programming.

Modeling binary numbers as an integer list of just 0 or 1 is very easy. List operations perform best when they work at the head, allowing you to have maximum sharing and least copying. So we reversed the number's list to express our algorithms.

We looked at addition and multiplication algorithms. Next, we covered the concept of greediness and backtracking. We saw how these concepts drive regular expression matching.

We then looked at a fun problem: how to satisfy an amount, given a set of coin denominations. We looked at the greedy version, which proved to be too greedy at times. This was fixed with a backtracking solution.

Hopefully, this ...

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