It is required to implement a map data structure which stores phone numbers (which is an integer) and
names (which is a string) This data structure should allow us to efficiently find the phone number given
the name
Which of the following data structures is most appropriate for this requirement
Pick the closest option
HashMap<String, String
HashMap<String int
HashMapInteger, String
HashMap<String Integer
HashMap Integer Integer
Submit
Solware Pvd
Siklons and
Answers
Answered by
2
The proper data structure for finding the contact number
HashMap<String, Integer>
- A collection of contacts in a big organization can be quite large. Employees often, based on the names of contacts, look up their phone numbers and email addresses.
- When there are only a few hundred contacts, searching for them or maintaining them is not so difficult even if only using for-loop.
- But when we have a thousand or more contacts, iterating down a list gets expensive. A way to look up the contact based on their names would simply things to a great extent.
- Using Hashtables, we can do such tasks easily as a hashtable maps keys (such as names) to their respective values (such as contact info) without traversing a data structure.
#SPJ3
Answered by
2
Answer:
HashMap<Integer, String>
Explanation:
In the question, it is clearly mentioned, that the data structure should contain phone number and name which is integer and string respectively.
Hence, The Hashmap of Integer and String is required. So, answer is HashMap<Integer, String>
#SPJ2
Similar questions