CS173: Intro to Computer Science - HashMaps

Activity Goals

The goals of this activity are:
  1. To identify the key-value relationship of the HashMap
  2. To use generic data types with Generic container classes

The Activity

Directions

Consider the activity models and answer the questions provided. First reflect on these questions on your own briefly, before discussing and comparing your thoughts with your group. Appoint one member of your group to take notes for the group, and appoint another member to discuss your findings with the class. After class, think about the questions in the reflective prompt and respond to those individually. Report out on areas of disagreement or items for which you and your group identified alternative approaches. Write down and report out questions you encountered along the way for group discussion.

Model 1: Data Maps

Nouveau Dictionnaire Larousse page
Telefonbog ubt-1

Questions

  1. Consider the dictionary and phone book above. When you look something up in each of them, what are you looking up, and what are you looking **for**? What are the data types?
  2. What are some ways that we make these lookups easier? How are the data organized, and what part of the data is organized that way?
  3. A phone book maps ______ to ______, and a dictionary maps ______ to ______.
  4. In computing, we tend to say that we map keys to values. For the phone book and dictionary, what is the key, and what is the value?

Model 2: The HashMap

Questions

  1. What is different about the data type that defines the HashMap variable in this program? What do the extra parameters mean?
  2. What would you change in the program above to store the number of students enrolled in each course, instead of the instructor of each course?
  3. What other types of data could you represent with a HashMap?
  4. Suppose you are developing a web browser that accesses web pages. You want to **cache** the pages, so that you only access them once, to save on I/O, network calls, and your data plan. How might a HashMap help you to do this? What would be the key and the value?

Model 3: A Complex HashMap

Questions

  1. What is browserCache mapping?
  2. What is the purpose of the additional HashMap?

Submission

Submit your answers to the questions using the Collaborative Spaces section of OneNote. You can add a page with your name and your group members' names, and today's date, as the title. Under the appropriate section (i.e., "Class Notes", "Collaborative Spaces", "Reflective Prompts") that you can select on the left side of the screen, you can click "Add Page" on the right side. You can answer any reflective prompt questions in the Reflective Journal section of your OneNote Classroom personal section.