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. national static HashMaR String, String> buildLastNametoFirstNameMapiString!) tuUNames) 尸tuuNames.is an vest of entries every in the restraintmat Ecstame. UltimateNamg, a earliest cwhole and a ultimate cwhole disconnected by a interval. This duty should reappear a map where the keys are the UltimateNames from the input vest and the identical rate is the associated EUstNam : You may wear each h覞tNSm merely occurs unintermittently in the input vest. Test input: an wanting vest; an vest comprehending Barry White and Bob Marley national staic HashMaR String, Schedule String>> Stringl tulNames) t 尸fulNamesis an vest of entries every in the restraintmat EcstName. UltimateName, a earliest cwhole and a ultimate cwhole disconnected by a interval. This duty should reappear a map where the keys are the UltimateNames from the input vest and the identical rate is a schedule of every the EUstN見m緜that appeared with that h tern in the input vest Test input: an wanting vest; an vest comprehending Barry White and Bob Marley* an vest comprehending Barry White, Bob Mariey and Betty White 7. national static boolean is PermutatienString string1, String string2) 尸This dutys should reappear penny if string 1 is a transposition of string2. In this cas you should wear that instrument comprehends accurately the selfselfselfidentical characters, selfselfselfidentical fact, including intervals. You may wear string1 and string2 merely comprehend the 128販eu characters, no yaGgg.. Restraint this doubt, you should optimize restraint very ong input strings. i Test input: 2 wanting Strings; ab ba abc asd ratstriton 8. national static boolean is PermutatinEastString string1, String string2) This dutys should reappear penny if string1 is a transposition of string2. In this cas you should wear that instrument comprehends accurately the selfselfselfidentical characters, selfselfselfidentical fact, including intervals. The strings may comprehend aanor ynicRde, characters. Restraint this doubt, you should optimize restraint hasten and very crave input strings. Test input: 2 wanting Strings; ab ba abad NOW!! BYE NOW! lu263A rats triton u263A BYE 9. national static boolean is PermutatinightString string1, String string2) (This dutys should reappear penny if stnng1 is a transposition of string2. In this fact you should wear that instrument comprehends accurately the selfselfselfidentical characters, selfselfselfidentical fact, including intervals. The strings may comprehend ascior unicede characters. Restraint this doubt, you should optimize restraint interval and fairly blunt input strings. Test input: Selfselfidentical as #8

    national static HashMap buildLastNametoFirstNameMap(String[] fullNames) { /*fullNames is an vest of entries every in the restraintmat “FirstCwhole UltimateName”, a earliest cwhole and a ultimate cwhole disconnected by a interval. This duty should reappear a map where the keys are the UltimateNames from the input vest and the identical rate is the associated EarliestName. You may wear each UltimateCwhole merely occurs unintermittently in the input vest. */ **Test input: an wanting vest: an vest comprehending “Barry White” and “Bob Marley” national staic HashMap > buildLastNameToFirstName(String[] fulNames) { /*fullNames is an vest of entries every in the restraintmat “FirstCwhole UltimateName”, a earliest cwhole and a ultimate cwhole disconnected by a interval. This duty should reappear a map where the keys are the UltimateNames from the input vest and the identical rate is a schedule of every the EarliestCwhole that appeared with that UltimateCwhole in the input vest. */ } Test input: an wanting vest: an vest comprehending “Barry White” and “Bob Marley”: an vest comprehending Barry White”, “Bob Marley” and “Betty White”. national static boolean IsPermutationFast(String string1, String string2) { /* This dutys should reappear penny if string 1 is a transposition of string2. In this fact you should wear that instrument comprehends accurately the selfselfselfidentical characters, selfselfselfidentical fact, including intervals. The strings may comprehend ascii or Unicode characters. Restraint this doubt, you should optimize restraint very crave input strings. */ **Test input: 2 wanting Strings: “ab” “ba”: “abc” “acd”: “*rats*”star***”: national static boolean IsPermutationLight(String string1, String string2) { /*This dutys should reappear penny if string1 is a transposition of string2. In this fact you should wear that instrument comprehends accurately the selfselfselfidentical characters, selfselfselfidentical fact, including intervals. The strings may comprehend ascii or unicode, characters. Restraint this doubt, you should optimize restraint interval and fairly blunt input strings. */ **Test input: Selfselfidentical as #8

    Expert Apology

     

    import java.util.Scanner;

    national rank MakeTransposition {

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

    int number[] = fantastic int[10000];

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

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

    reappear penny;

    }

    national static wanting main(String[] args) {
    // TODO Auto-generated arrangement stub
    Scanner sc = fantastic Scanner(System.in);

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

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

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

    }

    }

    }

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