Computer Science 112:

Introduction to Computer Science II

Gregory M. Kapfhammer

flickr photo by by physician1977 shared under a CC Public Domain Dedication (CC0)

Color Scheme

Key Concept

Corresponding Diagram

In-Class Discussion

In-Class Activity

Details in the Textbook

Limitations of the tree?

Still, not efficient searching!

HashTables to the rescue!

Well, sort of ...

Associative arrays

Key, value pairs






Counting words with a HashTable

What is the input?

What is the output?

How will the HashTable help?

How does the HashTable work?

Map k,v and lookup k quickly!

A Cool Function + An Array

See Figure 10.5!

Arbitrary objects

Hash code

Compression function

Bucket array

See Figure 10.5 for more details

What could go wrong with HashTables?

Collisions could make the search slower!

See Table 10.2 for time complexities

Discuss these time complexities

Expected versus worst-case?

Security implications of poor performance?

Denial of service attacks!

Insert data to cause poor performance

We will explore HashTables in an assignment

Any questions about HashTables?