Menu

Package Hw1 Import Javautiltreemap Public Class Hw1 Inverts Array Strings Returning Treema Q43829156

package hw1;

import java.util.TreeMap;

public class HW1 {
   /**
   * Inverts an array of Strings by returning a TreeMapthat maps Strings to the smallest index in the array that containsthe String.
   *
   * @param a an array of Strings
   * @return a Map that given a String returns thesmallest 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) {
           //TO DO
       return null;
   }
  
   /**
   * Computes the total number of occurrences of everyString in an array.
   *
   * @param a an array of Strings
   * @return a Map that given a String returns the numberof 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) {
       // TODO
       return null;
   }
}

Expert Answer


Answer to package hw1; import java.util.TreeMap; public class HW1 { /** * Inverts an array of Strings by returning a TreeMap that …

OR