Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Map Problems For each of the Map problems, you ll be taking a Map as a parameter ( even if it doesn t show up

Map Problems
For each of the Map problems, youll be taking a Map as a parameter (even if it doesnt show up in the method signature).
contains3
Implement a method that returns true if any string occurs at least 3 times in the input list, and false otherwise. Use a map as auxiliary storage. For example, consider the following list:
["373","is", "fun", "HI", "fun", "fun"]
contains3 should return true given this input because fun shows up at least 3 times.
intersect
Implement a method that takes as input two maps from Strings to Integers and returns a new map whose contents are the intersection of the two. The intersection of two maps is defined here as the set of keys-value pairs that exist in both maps. If some key K maps to value V in both the first and second map, include it in your result. If K does not exist as a key in both maps, or if K does not map to the same value V in both maps, exclude that pair from your result.
For example, consider the following two maps:
map1: {Janet=87, Logan=62, Whitaker=46, Alyssa=100, Stefanie=80, Jeff=88, Kim=52, Sylvia=95}
map2: {Logan=62, Kim=52, Whitaker=52, Jeff=88, Stefanie=80, Brian=60, Lisa=83, Sylvia=87}
Calling intersect(map1, map2) would return the following new map (the order of the key-value pairs does not matter):
{Logan=62, Stefanie=80, Jeff=88, Kim=52}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

Differentiate between intelligence testing and achievement testing.

Answered: 1 week ago

Question

Summarize life insurance and disability insurance.

Answered: 1 week ago

Question

Discuss voluntary benefits.

Answered: 1 week ago

Question

Identify employee service benefits.

Answered: 1 week ago