CS 310 Unit 9 Hash Tables - CS 310 Unit 9 Hash Tables...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 310 Unit 9 Hash Tables – Hashing  Functions Furman Haddix Ph.D. Assistant Professor Minnesota State University,  Mankato Spring 2008
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 310 Hash Tables Objectives Unit 9 Dynamic Sets Direct Addressing Hashing Functions Division Method Multiplication Method Universal Method (Matrix Method) Unit 10 Collisions Chaining Load Factors Open Addressing Perfect Hashing Text, Chapter 10
Background image of page 2
Dynamic Sets Sets may be dynamic or static Many mathematical sets, e.g., the set of real numbers,  the set of integers, the set of prime numbers, etc. are  static. Many of the sets on which algorithms operate are  dynamic The simplest dynamic sets are called  dictionaries Dictionaries  support the following operations: element *Search(set S, key k); // returns null if no member has key k bool Insert(set S, element *x); // returns true if successful; false, otherwise bool Delete(set S, element *x); // returns true if successful; false, otherwise
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Dictionary Implementations Arrays Supports O(1) Select, Delete, and Insert, if the index  is known.   Direct addressing Same general idea as array, but uses a key as the  index.  In general, the key k  must be unique, is greater than or equal 0 the set from which n keys are taken [0 … m] is  constrained such that m is not greatly larger than  n.  Hash tables Developed to deal with cases in which direct 
Background image of page 4
George, the Bolt maker George makes bolts using a bolt-making machine.  He deals with odd sizes of bolts and is usually able to  satisfy small requests from his inventory of 157 kinds  and sizes of bolts. Most of his revenue comes from larger requests, which  require him to make a production run.  Because of rejections, and the imperfections of the bolt- making process, it is difficult to make an exact quantity in  a production run. He needs to have a method for storing the excess bolts  and retrieving them for small orders. He would like to store his bolts in buckets, but his shop  doesn’t have room for 157 buckets. What can he do?
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
More on George, the Bolt-Maker Perhaps he can use fewer buckets. Requirements for fewer buckets: Store all the bolts Retrieve any size available  Systematic way of assigning sizes  Not too many sizes in one bucket Assume George does have room for say, 40 or so  buckets Possibilities: set bolt size (type?) limits on buckets, first bucket has size a or less, next bucket has larger than size a,  but size b or less, … {bucket sort approach} simple algorithm first bucket has 1/32, 1 1/32, 2 1/32, 3 1/32, …;  second bucket has 1/16, 1 1/16, 2 1/16, … {simple hashing  approach}
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/09/2008 for the course CS 310 taught by Professor Furmanhaddix during the Spring '08 term at Minnesota State University, Mankato.

Page1 / 29

CS 310 Unit 9 Hash Tables - CS 310 Unit 9 Hash Tables...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online