Skip to Content
Data Structures and Algorithms in C++, Second Edition
book

Data Structures and Algorithms in C++, Second Edition

by Michael T. Goodrich, Roberto Tamassia, David M. Mount
February 2011
Intermediate to advanced
736 pages
19h 35m
English
Wiley
Content preview from Data Structures and Algorithms in C++, Second Edition

Chapter 6. List and Iterator ADTs

List and Iterator ADTs

Contents

6.1 Vectors

228

6.1.1 The Vector Abstract Data Type

228

6.1.2 A Simple Array-Based Implementation

229

6.1.3 An Extendable Array Implementation

231

6.1.4 STL Vectors

236

6.2 Lists

238

6.2.1 Node-Based Operations and Iterators

238

6.2.2 The List Abstract Data Type

240

6.2.3 Doubly Linked List Implementation

242

6.2.4 STL Lists

247

6.2.5 STL Containers and Iterators

248

6.3 Sequences

255

6.3.1 The Sequence Abstract Data Type

255

6.3.2 Implementing a Sequence with a Doubly Linked List

255

6.3.3 Implementing a Sequence with an Array

257

6.4 Case Study: Bubble-Sort on a Sequence

259

6.4.1 The Bubble-Sort Algorithm

259

6.4.2 A Sequence-Based Analysis of Bubble-Sort

260

6.5 Exercises

262

Vectors

Suppose we have a collection S of n elements stored in a certain linear order, so that we can refer to the elements in S as first, second, third, and so on. Such a collection is generically referred to as a list or sequence. We can uniquely refer to each element e in S using an integer in the range [0,n − 1] that is equal to the number of elements of S that precede e in S. The index of an element e in S is the number of elements that are before e in S. Hence, the first element in S has index 0 and the last element has index n − 1. Also, if an element of S has index i, its previous element (if it exists) has index i − 1, and its next element (if it exists) has index i + 1. This concept of index ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Data Structures and Algorithms in Java, 2nd Edition

Data Structures and Algorithms in Java, 2nd Edition

Robert Lafore
Data Structures and Algorithms in Java, 6th Edition

Data Structures and Algorithms in Java, 6th Edition

Michael T. Goodrich, Roberto Tamassia
C++ Software Design

C++ Software Design

Klaus Iglberger
Hands-On Data Structures and Algorithms with Python - Second Edition

Hands-On Data Structures and Algorithms with Python - Second Edition

Dr. Basant Agarwal, Benjamin Baka, David Julian

Publisher Resources

ISBN: 9780470383278Purchase book