Using the Java library tools you have learned this semester (see code handout) implement the function...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Using the Java library tools you have learned this semester (see code handout) implement the function printDecrSize which when given a Map whose keys are type string and whose values are type ArrayList , prints all the entries in decreasing order by the size of their lists (ones with the same size can appear in any order). The method will not modify the given Map. For example, if the map had the following five entries (shown below in Map's toString format): {cceilr=[circle, cleric], hi=[hi], eiflr=[filer, flier, lifer, rifle], adn [and], chin= [inch, chin]} the output of calling print DecrSize on such a Map might be: eiflr: [filer, flier, lifer, rifle] chin: [inch, chin] cceilr: [circle, cleric] adn: [and] hi: [hi] i.e., entries in decreasing order by the size of their lists Hint: format for each ArrayList in the answer is just the normal tostring format. public static void print DecrSize (Map map) { [Java] Map Interface (selected methods) The classes that implement this interface are: TreeMap and HashMap. ValueType put (key, value) Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced by the specified value. Returns the previous value associated with specified key, or null if there was no mapping for key. ValueType get (key) Returns the value to which this map maps the specified key or null if the map contains no mapping for this key. boolean containsKey(key) Returns true iff the map contains a mapping for the specified key. ValueType remove (key) Removes the mapping for this key from this map if it is present, otherwise returns null. int size() boolean isEmpty() Number of key-value mappings in this map. Returns true if this map contains no key-value mappings. Set entrySet() Returns a set view of the entries contained in this map. Set keySet() Returns a set view of the keys contained in this map. [Java] Map. Entry Interface KeyType getKey() ValueType getValue() void setValue (newVal) Return the key of the entry Return the value of the entry Replace the current value with newVal Using the Java library tools you have learned this semester (see code handout) implement the function printDecrSize which when given a Map whose keys are type string and whose values are type ArrayList , prints all the entries in decreasing order by the size of their lists (ones with the same size can appear in any order). The method will not modify the given Map. For example, if the map had the following five entries (shown below in Map's toString format): {cceilr=[circle, cleric], hi=[hi], eiflr=[filer, flier, lifer, rifle], adn [and], chin= [inch, chin]} the output of calling print DecrSize on such a Map might be: eiflr: [filer, flier, lifer, rifle] chin: [inch, chin] cceilr: [circle, cleric] adn: [and] hi: [hi] i.e., entries in decreasing order by the size of their lists Hint: format for each ArrayList in the answer is just the normal tostring format. public static void print DecrSize (Map map) { [Java] Map Interface (selected methods) The classes that implement this interface are: TreeMap and HashMap. ValueType put (key, value) Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced by the specified value. Returns the previous value associated with specified key, or null if there was no mapping for key. ValueType get (key) Returns the value to which this map maps the specified key or null if the map contains no mapping for this key. boolean containsKey(key) Returns true iff the map contains a mapping for the specified key. ValueType remove (key) Removes the mapping for this key from this map if it is present, otherwise returns null. int size() boolean isEmpty() Number of key-value mappings in this map. Returns true if this map contains no key-value mappings. Set entrySet() Returns a set view of the entries contained in this map. Set keySet() Returns a set view of the keys contained in this map. [Java] Map. Entry Interface KeyType getKey() ValueType getValue() void setValue (newVal) Return the key of the entry Return the value of the entry Replace the current value with newVal
Expert Answer:
Related Book For
Posted Date:
Students also viewed these databases questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
Pritchett Company reported the following year-end data: Cash $ 25,000 8,000 Short-term investments Accounts receivable (current) Inventory 19,500 27,500 Prepaid (current) assets 11,000 Total current...
-
You have decided to open a company that produces wooden furniture, and you must select a suitable location for production. The first option is in a remote region of Montana with easy access to...
-
Assume that you enter into a long futures contract on gold when the futures price is $1,767 per ounce. The size of the contract is 2,000 ounces. The initial margin is $10,000 and the maintenance...
-
Twenty motors are put on an accelerated life test without replacement and the test is truncated after 5 failures. If the first 5 failures occurred at 12.5, 16.8, 24.3, 27.6 and 32.1 hours, assuming...
-
Believing that its traditional cost system may be providing misleading information, Dover Corporation is considering an activity-based costing (ABC) approach. Dover Corporation employs a full-cost...
-
Julie was a mother of a 3 year old daughter and a newborn baby boy who attended the family resource program on a weekly basis. Julie always had a positive attitude towards everything, even in times...
-
In investment valuation, why is a projection with the use of an income statement not sufficient? Calculate your own projection with an alternative method and think of your explanation to Mr. hirama
-
define and discuss the major differences between financial and managerial accounting compare and contrast accrual basis accounting with cash basis accounting how does a healthcare organization...
-
Dose healthcare organizations have educational videos to help employees make insurance decisions? Who helps them wade through all of the information out there? How do we make sure that the people who...
-
How does Green Credit act as a creditor and as a debtor in this scenario? Who would be Green Credit's creditor(s) and debtor(s)?
-
Johnson Department Store had net sales of $23 million and cost of goods sold of $12 million for the year. The beginning inventory for the year was $6 million. The ending inventory for the year was $1...
-
Online Vegan Sushi catering business - Evaluate your company's strengths, weaknesses, opportunities, and threats by conducting a SWOT Analysis. - Determine the main sources and intensity of...
-
Outline arguments for and against auditors being appointed by 1) a State agency and 2) a shareholder or stakeholder panel as a means of strengthening their independence.
-
Quality Chicken grows and processes chickens. Each chicken is disassembled into five main parts. Information pertaining to production in July 2012 is: Joint cost of production in July 2012 was $50. A...
-
Steam from an engine exhaust at 1.25 bar flows steadily through an electric calorimeter and comes out at \(1 \mathrm{bar}, 130^{\circ} \mathrm{C}\). The calorimeter has two \(\mathrm{kW}\) heaters...
-
The properties of water and steam become identical at (a) 0.1 bar (b) 1 bar (c) \(100 \mathrm{bar}\) (d) 212.2 bar.
-
In thermodynamic analysis, a pure substance is that which (a) Consists of only a single chemical species (b) has no dissolved impurities (c) may have a number of chemical species but the composition...
Study smarter with the SolutionInn App