O'Reilly logo

Functional Programming in Java: How functional techniques improve your Java programs by Pierre-Yves Saumont

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

Chapter 11. Solving real problems with advanced trees

This chapter covers

  • Avoiding stack overflow with self-balancing trees
  • Implementing the red-black tree
  • Creating functional maps
  • Designing a functional priority queue

In the previous chapter, you learned about the binary tree structure and basic tree operations. But you saw that to fully benefit from trees, you must either have very specific use cases, such as handling randomly ordered data, or a limited data set, in order to avoid any risk of stack overflows. Making trees stack-safe is much more difficult than it is for lists, because each computing step involves two recursive calls, which makes it impossible to create tail-recursive versions.

In this chapter, we’ll study two specific ...

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