Data Structures & Algorithms in Python

Learn how to use data structures effectively to write high performance Python programs and algorithms!

This text is packed with figures and easy to understand descriptions of how data structures help organize and accelerate the programs that power today's information systems. It teaches you how to choose the right data structure for an application and how each structure operates.

Understanding how efficiently data structures operate helps you judge how they perform on larger and larger data sets. The order of complexity of algorithms determines what scale of data they can handle. This book explains how to measure that complexity and gently introduces the math needed to understand it.

The widespread adoption of Python makes this text accessible to most novice programmers. If you haven't used Python yet but have written programs in other object-oriented languages, a quick introduction at the beginning teaches you the basics. All of the code is available from the Downloads page so you can try out the examples.

Best of all, an open-source set of visualization tools gives you direct control of each of the data structures. You can try out different operations and step through the code to see how the structures and algorithms work together to produce results.


Order your copy today at one of these sites worldwide Pearson/InformIT, Abe Books, Akademika, Amazon, Angus & Robertson, Barnes and Noble, Blackwell's, Booktopia, BuscaLibre, Chegg, Dussman, Dymocks, Hive, IBS, JPC, Standaard Boekhandel, Thriftbooks, Tomlinsons, W H Smith, Waterstones, and more.

As an Amazon Associate this site earns from qualifying purchases.


Data Structures & Algorithms in Python brings the core concepts of computer science to life with extensive descriptions, full calor figures, richly commented code, and interactive visualizations.

Inserting an item into a circular queue

Each chapter introduces a kind of data structure or algorithm category, starting with the most basic, the array. Readers build mastery of each topic from the text, illustrations, code, and visualizations. At the end of each chapter, review questions with answers, thought excercises, and programming projects reinforce the new concepts.

We cover all the fundamental data structures:

  • Arrays
  • Stacks
  • Queues
  • Priority Queues
  • Linked lists
    • Singly linked
    • Doubly linked
    • Double-ended
    • Circular
  • Iterators
  • Trees
    • Binary search trees
    • 2-3-4 trees
    • AVL trees
    • Red-black trees
  • Hash tables
  • Spatial data structures
    • Point lists
    • Grids
    • Quadtrees
  • Heaps
  • Unweighted graphs
  • Weighted graphs

Algorithms covered:

  • Sorting
    • Bubble sort
    • Selection sort
    • Insertion sort
    • Shellsort
    • Mergesort
    • Quicksort
    • Partitioning
    • Radix sort
    • Timsort
  • Recursion (when to use and how to eliminate)
  • Parsing arithmetic expressions
  • Binary search
  • Tower of Hanoi
  • Huffman coding
  • Minimum spanning tree
  • Topological sorting
  • Shortest path
  • All pairs shortest path


Everyone learns better by doing. The visualizations developed for this book let you work with the individual operations of each data structure. The visualization tools display the various pieces of data as they are manipulated by different algorithms. The same code as shown in the text appears with highlighting to show the execution. Controls let you slow down, speed up, and step through each algorithm.

Animation of the Heap Visualization Tool during Heapify

See the visualizations live on the visualization page or better yet, download them to run on your local machine.


On the downloads archive page you can find all versions of:

  • The visualizations bundled for macOS and Windows.
  • All current errata availble for the textbook.
  • The source code shown in the textbook, grouped by chapter.
  • The figures used as prototypes of figures in the textbook. These are great for making slides for lectures.

Contact Us

Please let us know what you think about the book and other materials. Use the form below to send the authors questions or comments.

If you would like to request the sample program solutions, please provide us your name and a link to a page showing your status as a qualified instructor.

Cover image of Data Structures & Algorithms in Python