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
Q2: Mark True or False in the corresponding Answer sheet (0.5 point each)
Zinaida [17]

The answers to the question are:

  1. True
  2. True
  3. True
  4. True
  5. False
  6. true
  7. True
  8. True
  9. False
  10. False
  11. false
  12. False
  13. True
<h3>Which words are combined to form malware?</h3>

Malware is known to be a kind of malicious software and it covers  viruses, worms, trojans and other bad computer programs that is often used by hackers to wreak and steal information from system.

The types Of Expansion Cards are:

  • Sound Card
  • Graphics Card
  • Network Interface Card
  • Modem,

A sound card known as an audio card which is said to be an internal expansion card that helps to give input and output of audio message to and from a computer system.

Learn more about  sound card from

brainly.com/question/26964065

#SPJ1

3 0
2 years ago
A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is 50, then th
Kipish [7]

Answer:

(target - 10 ≤ score) AND (score ≤ target + 10)

Explanation:

8 0
3 years ago
Need answer ASAP plz
Natalka [10]

Answer:

i can't read a single word on there i'll come back to it if you can zoom in a little

Explanation:

6 0
3 years ago
BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLI
olganol [36]

Answer:

I think the answer is network

hope this helps

have a good day :)

Explanation:

7 0
3 years ago
Read 2 more answers
Whether you work in m-commerce, e-commerce, or brick-and-mortar commerce, to be successful you will need to be able to think cri
svlad2 [7]

Answer:

The answer is "Option c"

Explanation:

Decisions made in secret have always been critical. Hence the want to express it before your choice is made. It is all about how you express choice. In general, they need your presentation to explain the choice that you decided, how they created it, and how it implies for just the group, that you are approaching, and wrong choices can be described as follows:

  • In option a, It is used in the industry to interest.
  • In option b, It is use in communication mechanism.
  • In option d, It enables people to handle our activities or carry them out.
3 0
3 years ago
Other questions:
  • You've formatted the first paragraph of a document. What button can you use to apply the formatting from the first paragraph to
    9·2 answers
  • Which of the following is true? A)Checks and Debit Cards both withdraw money directly from a bank account. B)Checks are the most
    13·2 answers
  • Does time complexity depend on, which base arithmetic you use? like base 10, 2 or whatever else? Does time coplexity depned on t
    13·1 answer
  • Read the scenario below. Explain why this is not fair use of copyright materials. What should you do instead of using the entire
    10·1 answer
  • Write a program which capitalize every character after full stopin a given sentence
    11·1 answer
  • what is the total resistance of a series circuit with four resistors in series of 12 16 20 and 24 ohms​
    14·1 answer
  • Which elements of a myth appear in this story from early babylon
    14·1 answer
  • A recursive method may call other methods, including calling itself. A recursive method has:
    7·1 answer
  • Hola, alguien aquí me podría ayudar dándome ideas a cerca de office (Word, PowerPoint o Excel) estoy desesperada no puedo pensar
    11·1 answer
  • What is the launching of a 3-D map called?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!