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 discuss your findings with the class, and the rest of the group should help that member prepare their response. Answer each question individually from the activity on the Class Activity Questions discussion board. After class, think about the questions in the reflective prompt and respond to those individually in your notebook. 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 Class Activity Questions discussion board. You may also respond to questions or comments made by others, or ask follow-up questions there. Answer any reflective prompt questions in the Reflective Journal section of your OneNote Classroom personal section.