2. Arrays

Arrays are the most commonly used data structure for many reasons. They are straightforward to understand and match closely the underlying computer hardware. Almost all CPUs make it very fast to access data at known offsets from a base address. Almost every programming language supports them as part of the core data structures. We study them first for their simplicity and because many of the more complex data structures are built using them.

In This Chapter

The Array Visualization Tool

Using Python Lists to Implement the Array Class

The Ordered Array Visualization Tool

Binary Search

Python Code for an Ordered Array Class

Logarithms

Storing Objects

Big O Notation

Why Not Use Arrays for Everything?

First, we look at ...

Get Data Structures & Algorithms in Python now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.