Algorithm Analysis (CSC 301 2015F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Outline] [EBoard] [Reading] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Algorist]
Related Courses: [Walker (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Overview
What do you see as the key ideas of hash tables?
hash(key) % array.size)We will get duplication: Two key/values will try to fit into the the same slot in the array. What do we do?
Do we still get expected constant time get/set?
What are some design choices you have to make in implementing hash tables?
With your group
Function borrowed from Skienna p. 89; expects arbitrary-precision integers
#define alpha SOME_LARGE_PRIME
int hash(char *s)
{
int len = strlen(s);
int code = 0;
for (int i = 0; i < len; i++)
{
code += s[i] * expt(alpha, len-(i+1))
} // for
return code;
} // hash
hash(substring(str, 0, k)) and hash(substring(str, 1, k+1))?
E.g., hash(substring(str, 0, 6) vs hash(substring(str, 1, 7))
(hash(substring(str,0,6)) - str[0]*expt(alpha,6))*alpha + str[7]Ideas stolen from Skiena
How could you use hash functions or tables to help you ...
a is a substring of string b?