Skip to main content Accessibility help
×
Hostname: page-component-76fb5796d-dfsvx Total loading time: 0 Render date: 2024-04-28T06:13:21.262Z Has data issue: false hasContentIssue false

Chapter 10 - Hashing and the HashTable Class

Published online by Cambridge University Press:  11 August 2009

Michael McMillan
Affiliation:
Pulaski Technical College, Arkansas
Get access

Summary

Hashing is a very common technique for storing data in such a way that the data can be inserted and retrieved very quickly. Hashing uses a data structure called a hash table. Although hash tables provide fast insertion, deletion, and retrieval, they perform poorly for operations that involve searching, such as finding the minimum or maximum value. For these types of operations, other data structures are preferred (see, for example, Chapter 14 on binary search trees).

The.NET Framework library provides a very useful class for working with hash tables, the Hashtable class. We will examine this class in this chapter, but we will also discuss how to implement a custom hash table. Building hash tables is not very difficult and the programming techniques used are well worth knowing.

AN OVERVIEW OF HASHING

A hash table data structure is designed around an array. The array consists of elements 0 through some predetermined size, though we can increase the size later if necessary. Each data item is stored in the array based on some piece of the data, called the key. To store an element in the hash table, the key is mapped into a number in the range of 0 to the hash table size using a function called a hash function.

Ideally, the hash function stores each key in its own cell in the array.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2005

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Hashing and the HashTable Class
  • Michael McMillan, Pulaski Technical College, Arkansas
  • Book: Data Structures and Algorithms Using Visual Basic.NET
  • Online publication: 11 August 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511547010.012
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Hashing and the HashTable Class
  • Michael McMillan, Pulaski Technical College, Arkansas
  • Book: Data Structures and Algorithms Using Visual Basic.NET
  • Online publication: 11 August 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511547010.012
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Hashing and the HashTable Class
  • Michael McMillan, Pulaski Technical College, Arkansas
  • Book: Data Structures and Algorithms Using Visual Basic.NET
  • Online publication: 11 August 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511547010.012
Available formats
×