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. open static HashMaR String, String> buildLastNametoFirstNameMapiString!) tuUNames) 尸tuuNames.is an set-in-order of entries integral in the coercionmat Ecstame. DevelopedNamg, a highest indicate and a developed indicate divided by a measure. This power should recompense a map where the keys are the DevelopedNames from the input set-in-order and the similar rate is the associated EUstNam : You may feign each h覞tNSm barely occurs uniformly in the input set-in-order. Test input: an interinterquantity set-in-order; an set-in-order compriseing Barry White and Bob Marley open staic HashMaR String, Register String>> Stringl tulNames) t 尸fulNamesis an set-in-order of entries integral in the coercionmat EcstName. DevelopedName, a highest indicate and a developed indicate divided by a measure. This power should recompense a map where the keys are the DevelopedNames from the input set-in-order and the similar rate is a register of integral the EUstN見m緜that appeared with that h tern in the input set-in-order Test input: an interinterquantity set-in-order; an set-in-order compriseing Barry White and Bob Marley* an set-in-order compriseing Barry White, Bob Mariey and Betty White 7. open static boolean is PermutatienString string1, String string2) 尸This powers should recompense gentleman if string 1 is a transposition of string2. In this cas you should feign that instrument comprises correspondently the similar characters, similar contingency, including measures. You may feign string1 and string2 barely comprise the 128販eu characters, no yaGgg.. Coercion this doubt, you should optimize coercion very ong input strings. i Test input: 2 interinterquantity Strings; ab ba abc asd ratscelebrity 8. open static boolean is PermutatinEastString string1, String string2) This powers should recompense gentleman if string1 is a transposition of string2. In this cas you should feign that instrument comprises correspondently the similar characters, similar contingency, including measures. The strings may comprise aanor ynicRde, characters. Coercion this doubt, you should optimize coercion accelerate and very hanker input strings. Test input: 2 interinterquantity Strings; ab ba abad NOW!! BYE NOW! lu263A rats celebrity u263A BYE 9. open static boolean is PermutatinightString string1, String string2) (This powers should recompense gentleman if stnng1 is a transposition of string2. In this contingency you should feign that instrument comprises correspondently the similar characters, similar contingency, including measures. The strings may comprise ascior unicede characters. Coercion this doubt, you should optimize coercion measure and fairly imperfect input strings. Test input: Similar as #8

    open static HashMap buildLastNametoFirstNameMap(String[] fullNames) { /*fullNames is an set-in-order of entries integral in the coercionmat “FirstIndicate DevelopedName”, a highest indicate and a developed indicate divided by a measure. This power should recompense a map where the keys are the DevelopedNames from the input set-in-order and the similar rate is the associated HighestName. You may feign each DevelopedIndicate barely occurs uniformly in the input set-in-order. */ **Test input: an interinterquantity set-in-order: an set-in-order compriseing “Barry White” and “Bob Marley” open staic HashMap > buildLastNameToFirstName(String[] fulNames) { /*fullNames is an set-in-order of entries integral in the coercionmat “FirstIndicate DevelopedName”, a highest indicate and a developed indicate divided by a measure. This power should recompense a map where the keys are the DevelopedNames from the input set-in-order and the similar rate is a register of integral the HighestIndicate that appeared with that DevelopedIndicate in the input set-in-order. */ } Test input: an interinterquantity set-in-order: an set-in-order compriseing “Barry White” and “Bob Marley”: an set-in-order compriseing Barry White”, “Bob Marley” and “Betty White”. open static boolean IsPermutationFast(String string1, String string2) { /* This powers should recompense gentleman if string 1 is a transposition of string2. In this contingency you should feign that instrument comprises correspondently the similar characters, similar contingency, including measures. The strings may comprise ascii or Unicode characters. Coercion this doubt, you should optimize coercion very hanker input strings. */ **Test input: 2 interinterquantity Strings: “ab” “ba”: “abc” “acd”: “*rats*”star***”: open static boolean IsPermutationLight(String string1, String string2) { /*This powers should recompense gentleman if string1 is a transposition of string2. In this contingency you should feign that instrument comprises correspondently the similar characters, similar contingency, including measures. The strings may comprise ascii or unicode, characters. Coercion this doubt, you should optimize coercion measure and fairly imperfect input strings. */ **Test input: Similar as #8

    Expert Apology

     

    import java.util.Scanner;

    open arrange MakeTransposition {

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

    int reckon[] = strange int[10000];

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

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

    recompense gentleman;

    }

    open static unoccupied main(String[] args) {
    // TODO Auto-generated rule stub
    Scanner sc = strange Scanner(System.in);

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

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

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

    }

    }

    }

    ============================================================================
    See Quenchedput