====== Week 11 ====== ~~NOTOC~~ ==== Tuesday ==== * questions on the lab? * Today, we cover maps and hash maps. * For reference, let's take a quick look at name/value pairs for a mainframe OS * [[https://www.ibm.com/docs/en/ztpf/2020?topic=functions-name-value-pair-support|What is a name/value pair?]] * perhaps a simpler construct: a dictionary! * {{ :courses:cs102-2021-01:102-week11-1.pptx |lecture notes}} * {{ :courses:cs102-2021-01:mapexample.zip |map code project}} ==== Thursday ==== * Quick Summary from Tuesday'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 * [[https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--|we will need the hashCode() method]] * Today, and tomorrow, we will implement our own hash map data structure * {{ :courses:cs102-2021-01:week11-hashmap.zip |Bluej project}} * UPDATE THE CODE WE STARTED TO DEVELOP IS HERE! * {{ :courses:cs102-2021-01:myhashmap.java.tar.gz |MyHashMap}} ==== Friday's Lab ==== * It is located here, be sure to pick up the MyHashMap java file above, I added it last evening. * [[https://moodle.vassar.edu/course/view.php?id=19557#section-2|moodle link]] * The key, so to speak, of using the KeyValuePair is to remember to use the generics: ''>'' ==== Interesting, or not! ==== [[https://betterprogramming.pub/4-kinds-of-programming-advice-i-wish-my-younger-self-knew-ac3572549ce5|Check out the author page too!]]