1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yKpoI14uk [10]
3 years ago
10

Package hw1;

Computers and Technology
1 answer:
kotykmax [81]3 years ago
3 0

Answer:

The Java code is given below with appropriate comments in key areas of the code

Explanation:

import java.util.TreeMap;

public class HW1 {

       /**

        * Inverts an array of Strings by returning a TreeMap that maps Strings to the

        * smallest index in the array that contains the String.

        *

        * @param a an array of Strings

        * @return a Map that given a String returns the smallest index of the array

        *         that contains the String (or null if String is not in the array a).

        */

       public static TreeMap<String, Integer> invert(String[] a) {

               TreeMap<String, Integer> tmap = new TreeMap<>();

               for (int i = 0; i < a.length; i++) {

                       if (!tmap.containsKey(a[i])) {

                               tmap.put(a[i], i);

                       }

               }

               return tmap;

       }

       /**

        * Computes the total number of occurrences of every String in an array.

        *

        * @param a an array of Strings

        * @return a Map that given a String returns the number of occurrences of that

        *         String in the array (or null if String is not in the array a).

        */

       public static TreeMap<String, Integer> count(String[] a) {

               TreeMap<String, Integer> tmap = new TreeMap<>();

               for (int i = 0; i < a.length; i++) {

                       tmap.put(a[i], 1 + tmap.getOrDefault(a[i], 0));

               }

               return tmap;

       }

}

You might be interested in
Which mechanical switches are the loudest and clickiest?
telo118 [61]

Answer:

1.Cherry MX Blue

2.most expensive is Gateron Blue

3 0
3 years ago
Which change signaled a musical progression toward rock and roll?
postnew [5]
It is the inclusion of the bass section
7 0
4 years ago
Text that is positioned at the top of a column and labels the<br> column.
Vanyuwa [196]

Answer:

column header

Explanation:

3 0
3 years ago
PHOTOGRAPHY
Natasha_Volkova [10]

Answer:

false

Explanation:

when you zoom in it mkes it bigger and closer not smaller and farther

hope this helps :)

8 0
3 years ago
Read 2 more answers
Once we have reached complete efficiency in the third part of the LRAS Curve, what occurs?
sergiy2304 [10]

your answer is c hope this helps


8 0
4 years ago
Other questions:
  • What's a qat on a computer
    12·2 answers
  • Plese give three examples of specilized servers.
    13·2 answers
  • Bonnie gets very nervous before taking tests. What can she do to help her anxiety while she takes her tests?
    15·2 answers
  • NEED BY 15 MINUTES PLEASE! WILL MARK BRAINLIEST!You can create special effects in an image using a camera or a photo-editing too
    5·1 answer
  • What type of Microsoft Server serves as an email server?
    7·2 answers
  • Join my disc server "the angels"<br><br> https://dis cord.gg/PYnWArCz<br><br><br> tyyy
    5·1 answer
  • Dennis would like to include a video in a presentation. The source of the video is on the internet, but he would like to ensure
    10·2 answers
  • _ is a term used for license like those issues by creative commons license as an alternative to copyright
    8·1 answer
  • Please help i will give you brainlest!!!!!!!!!
    6·1 answer
  • The EDI ____________layer describes the business application that i
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!