6 Tries and Adapting Data Structures

Binary search trees, while incredibly powerful, are only one way of using a tree structure to better organize data. Instead of splitting our data sets based on less-than or greater-than comparisons, we can optimize how the tree splits the data for the specific search problem at hand. In this chapter, for example, we tackle the problem of storing and searching strings in trees. Extending the binary search tree’s general branching approach to capture additional structure within the data enables us to search efficiently for target strings in a set of strings.

We begin by discussing how binary search trees ...

Get Data Structures the Fun Way now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.