O'Reilly logo

Data Structures and Algorithms Using Python by Rance D. Necaise

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 3. Sets and Maps

In the previous chapters, we studied several complex abstract data types that required the use of a data structure for their implementation. In this chapter, we continue exploring abstract data types with a focus on several common containers. Two of these are provided by Python as part of the language itself: sets and dictionaries. Nevertheless, it's still important to understand how they work and some of the common ways in which they are implemented.

Your experience in programming will likely not be limited to the Python language. At some point in the future, you may use one if not several other common programming languages. While some of these do provide a wide range of abstract data types as part of the language itself or included in their standard library, others, like C, do not. Thus, it's important that you know how to implement a set or dictionary ADT if necessary, when one is not available as part of the language.

Further, both the set and dictionary types provide excellent examples of abstract data types that can be implemented using different data structures. As you learned in Chapter 1, there may be multiple data structures and ways to organize the data in those structures that are suitable for implementing an abstract data type. Thus, it's not uncommon for language libraries to provide multiple implementations of an abstract data type, which allows the programmer to choose the best option for a given problem. Your ability to choose from among these ...

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