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 9. Hash Tables, Maps, and Skip Lists

Hash Tables, Maps, and Skip Lists

Contents

9.1 Maps

368

9.1.1 The Map ADT

369

9.1.2 A C++ Map Interface

371

9.1.3 The STL map Class

372

9.1.4 A Simple List-Based Map Implementation

374

9.2 Hash Tables

375

9.2.1 Bucket Arrays

375

9.2.2 Hash Functions

376

9.2.3 Hash Codes

376

9.2.4 Compression Functions

380

9.2.5 Collision-Handling Schemes

382

9.2.6 Load Factors and Rehashing

386

9.2.7 A C++ Hash Table Implementation

387

9.3 Ordered Maps

394

9.3.1 Ordered Search Tables and Binary Search

395

9.3.2 Two Applications of Ordered Maps

399

9.4 Skip Lists

402

9.4.1 Search and Update Operations in a Skip List

404

9.4.2 A Probabilistic Analysis of Skip Lists *

408

9.5 Dictionaries

411

9.5.1 The Dictionary ADT

411

9.5.2 A C++ Dictionary Implementation

413

9.5.3 Implementations with Location-Aware Entries

415

9.6 Exercises

417

Maps

A conceptual illustration of the map ADT. Keys (labels) are assigned to values (folders) by a user. The resulting entries (labeled folders) are inserted into the map (file cabinet). The keys can be used later to retrieve or remove values.

Figure 9.1. A conceptual illustration of the map ADT. Keys (labels) are assigned to values (folders) by a user. The resulting entries (labeled folders) are inserted into the map (file cabinet). The keys can be used later to retrieve or remove values.

A map allows us to store elements so they can be located quickly using keys. The motivation for such searches is that each element typically stores additional useful information besides its search key, but the only way to get at that information is to use the search ...

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