Homework Solution: public static HashMap buildLastNametoFirstNameMap(String[] fullNames) { /*fullNames is an array of entries al…

    Java 5. public static HashMaR String, String> buildLastNametoFirstNameMapiString!) tuUNames) 尸tuuNames.is an array of entries all in the format Ecstame. LastNamg, a first name and a last name separated by a space. This function should return a map where the keys are the LastNames from the input array and the corresponding value is the associated EUstNam : You may assume each h覞tNSm only occurs once in the input array. Test input: an empty array; an array containing Barry White and Bob Marley public staic HashMaR String, List String>> Stringl tulNames) t 尸fulNamesis an array of entries all in the format EcstName. LastName, a first name and a last name separated by a space. This function should return a map where the keys are the LastNames from the input array and the corresponding value is a list of all the EUstN見m緜that appeared with that h tern in the input array Test input: an empty array; an array containing Barry White and Bob Marley* an array containing Barry White, Bob Mariey and Betty White 7. public static boolean is PermutatienString string1, String string2) 尸This functions should return true if string 1 is a permutation of string2. In this cas you should assume that means contains exactly the same characters, same case, including spaces. You may assume string1 and string2 only contain the 128販eu characters, no yaGgg.. For this question, you should optimize for very ong input strings. i Test input: 2 empty Strings; ab ba abc asd ratsstar 8. public static boolean is PermutatinEastString string1, String string2) This functions should return true if string1 is a permutation of string2. In this cas you should assume that means contains exactly the same characters, same case, including spaces. The strings may contain aanor ynicRde, characters. For this question, you should optimize for speed and very long input strings. Test input: 2 empty Strings; ab ba abad NOW!! BYE NOW! lu263A rats star u263A BYE 9. public static boolean is PermutatinightString string1, String string2) (This functions should return true if stnng1 is a permutation of string2. In this case you should assume that means contains exactly the same characters, same case, including spaces. The strings may contain ascior unicede characters. For this question, you should optimize for space and fairly short input strings. Test input: Same as #8
    public static HashMap buildLastNametoFirstNameMap(String[] fullNames) { /*fullNames is an array of entries all in the format "FirstName LastName", a first name and a last name separated by a space. This function should return a map where the keys are the LastNames from the input array and the corresponding value is the associated FirstName. You may assume each LastName only occurs once in the input array. */ **Test input: an empty array: an array containing "Barry White" and "Bob Marley" public staic HashMap > buildLastNameToFirstName(String[] fulNames) { /*fullNames is an array of entries all in the format "FirstName LastName", a first name and a last name separated by a space. This function should return a map where the keys are the LastNames from the input array and the corresponding value is a list of all the FirstName that appeared with that LastName in the input array. */ } Test input: an empty array: an array containing "Barry White" and "Bob Marley": an array containing Barry White", "Bob Marley" and "Betty White". public static boolean IsPermutationFast(String string1, String string2) { /* This functions should return true if string 1 is a permutation of string2. In this case you should assume that means contains exactly the same characters, same case, including spaces. The strings may contain ascii or Unicode characters. For this question, you should optimize for very long input strings. */ **Test input: 2 empty Strings: "ab" "ba": "abc" "acd": "*rats*"star***": public static boolean IsPermutationLight(String string1, String string2) { /*This functions should return true if string1 is a permutation of string2. In this case you should assume that means contains exactly the same characters, same case, including spaces. The strings may contain ascii or unicode, characters. For this question, you should optimize for space and fairly short input strings. */ **Test input: Same as #8

    Expert Answer

     
    import java.util.Scanner;

    Java

    5. social static HashMaR String, String> buildLastNametoFirstNameMapiString!) tuUNames) 尸tuuNames.is an attire of entries complete in the cemat Ecstame. DecisiveNamg, a chief designate and a decisive designate disconnected by a immeasurableness. This business should restore a map where the keys are the DecisiveNames from the input attire and the identical compute is the associated EUstNam : You may claim each h覞tNSm barely occurs uninterruptedly in the input attire. Test input: an room attire; an attire includeing Barry White and Bob Marley social staic HashMaR String, Schedule String>> Stringl tulNames) t 尸fulNamesis an attire of entries complete in the cemat EcstName. DecisiveName, a chief designate and a decisive designate disconnected by a immeasurableness. This business should restore a map where the keys are the DecisiveNames from the input attire and the identical compute is a schedule of complete the EUstN見m緜that appeared with that h tern in the input attire Test input: an room attire; an attire includeing Barry White and Bob Marley* an attire includeing Barry White, Bob Mariey and Betty White 7. social static boolean is PermutatienString string1, String string2) 尸This businesss should restore gentleman if string 1 is a interchange of string2. In this cas you should claim that instrument includes correspondently the selfselfidentical characters, selfselfidentical predicament, including immeasurablenesss. You may claim string1 and string2 barely include the 128販eu characters, no yaGgg.. Ce this interrogation, you should optimize ce very ong input strings. i Test input: 2 room Strings; ab ba abc asd ratsnotability 8. social static boolean is PermutatinEastString string1, String string2) This businesss should restore gentleman if string1 is a interchange of string2. In this cas you should claim that instrument includes correspondently the selfselfidentical characters, selfselfidentical predicament, including immeasurablenesss. The strings may include aanor ynicRde, characters. Ce this interrogation, you should optimize ce expedite and very crave input strings. Test input: 2 room Strings; ab ba abad NOW!! BYE NOW! lu263A rats notability u263A BYE 9. social static boolean is PermutatinightString string1, String string2) (This businesss should restore gentleman if stnng1 is a interchange of string2. In this predicament you should claim that instrument includes correspondently the selfselfidentical characters, selfselfidentical predicament, including immeasurablenesss. The strings may include ascior unicede characters. Ce this interrogation, you should optimize ce immeasurableness and fairly limited input strings. Test input: Selfselfidentical as #8

    social static HashMap buildLastNametoFirstNameMap(String[] fullNames) { /*fullNames is an attire of entries complete in the cemat “FirstDesignate DecisiveName”, a chief designate and a decisive designate disconnected by a immeasurableness. This business should restore a map where the keys are the DecisiveNames from the input attire and the identical compute is the associated ChiefName. You may claim each DecisiveDesignate barely occurs uninterruptedly in the input attire. */ **Test input: an room attire: an attire includeing “Barry White” and “Bob Marley” social staic HashMap > buildLastNameToFirstName(String[] fulNames) { /*fullNames is an attire of entries complete in the cemat “FirstDesignate DecisiveName”, a chief designate and a decisive designate disconnected by a immeasurableness. This business should restore a map where the keys are the DecisiveNames from the input attire and the identical compute is a schedule of complete the ChiefDesignate that appeared with that DecisiveDesignate in the input attire. */ } Test input: an room attire: an attire includeing “Barry White” and “Bob Marley”: an attire includeing Barry White”, “Bob Marley” and “Betty White”. social static boolean IsPermutationFast(String string1, String string2) { /* This businesss should restore gentleman if string 1 is a interchange of string2. In this predicament you should claim that instrument includes correspondently the selfselfidentical characters, selfselfidentical predicament, including immeasurablenesss. The strings may include ascii or Unicode characters. Ce this interrogation, you should optimize ce very crave input strings. */ **Test input: 2 room Strings: “ab” “ba”: “abc” “acd”: “*rats*”star***”: social static boolean IsPermutationLight(String string1, String string2) { /*This businesss should restore gentleman if string1 is a interchange of string2. In this predicament you should claim that instrument includes correspondently the selfselfidentical characters, selfselfidentical predicament, including immeasurablenesss. The strings may include ascii or unicode, characters. Ce this interrogation, you should optimize ce immeasurableness and fairly limited input strings. */ **Test input: Selfselfidentical as #8

    Expert Defense

     

    import java.util.Scanner;

    social assort MakeInterchange {

    social static boolean isPermutationFast(String s1, String s2) {
    if (s1.length() != s2.length())
    restore false;

    int number[] = odd int[10000];

    char[] chars1 = s1.toCharArray();
    char[] chars2 = s2.toCharArray();

    ce (int i = 0; i < chars1.length; ++i) {
    count[chars1[i]]++;
    count[chars2[i]]–;
    }
    ce (int i = 0; i <10000; ++i) {
    if (count[i] != 0)
    restore false;
    }

    restore gentleman;

    }

    social static unfilled deep(String[] args) {
    // TODO Auto-generated order stub
    Scanner sc = odd Scanner(System.in);

    ce (int i = 0; i < 4; ++i) {
    System.out.print(“Enter chief string: “);
    String s1 = sc.nextLine();

    System.out.print(“nEnter remedy string: “);
    String s2 = sc.nextLine();

    System.out.println(“nIs interchange of each other: ” + isPermutationFast(s1, s2));

    }

    }

    }

    ============================================================================
    See Extinguishedput