Week 11
Tuesday
- questions on the lab?
- Today, we cover maps and hash maps.
- For reference, let039;s take a quick look at name/value pairs for a mainframe OS
- perhaps a simpler construct: a dictionary!
Thursday
- Quick Summary from Tuesday039;s lecture on hash maps, or hash tables:
- hash function is a way to mash up (my term) the name of something into a numerical key
- the % operator is one way to lower/minimize the number of possible keys into a manageable number of buckets
- we use buckets to hold one or more values based on the key
- with a small range of keys, we can use an array data structure to O(1) access a bucket and we can represent a bucket with a linked list data structure.
- if the number of keys available is too small for the number of values we are using, we approach O(n) accesses to get values (no difference from a linked list & no advantage to using a hash map!) so we may want to resize
- Today, and tomorrow, we will implement our own hash map data structure
- UPDATE THE CODE WE STARTED TO DEVELOP IS HERE!
Friday039;s Lab
- It is located here, be sure to pick up the MyHashMap java file above, I added it last evening.
- The key, so to speak, of using the KeyValuePair is to remember to use the generics:
<KeyValuePair<K,V»