Chapter 7
Linked Lists
Contents
7.1.1 Implementing a Stack with a Singly Linked List
7.1.2 Implementing a Queue with a Singly Linked List
7.2.2 Implementing a Queue with a Circularly Linked List
7.3.1 Basic Implementation of a Doubly Linked List
7.3.2 Implementing a Deque with a Doubly Linked List
7.4.1 The Positional List Abstract Data Type
7.4.2 Doubly Linked List Implementation
7.6 Case Study: Maintaining Access Frequencies
7.6.2 Using a List with the Move-to-Front Heuristic
In Chapter 5 we carefully examined Python's array-based list class, and in Chapter 6 we demonstrated use of that class in implementing the classic stack, queue, and dequeue ADTs. Python's list class is highly optimized, and often a great choice for storage. With that said, there are some notable disadvantages:
- The length of a dynamic array might be longer than the actual number of elements that it stores.
- Amortized bounds for operations may be unacceptable in real-time systems.
- Insertions and deletions at interior positions of an array are expensive.
In this chapter, we introduce a data structure known as a linked list, which provides an alternative to an array-based ...
Get Data Structures and Algorithms in Python 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.