Homework Solution: Add a main so that you can put some code there to call your functions and make sure they work:…

    Add a main so that you can put some code there to call your functions and make sure they work: public static void main(String[] args) { /* your testing code goes here */ } Functions you should add if the functionality is possible. Otherwise add an empty function definition with a comment saying "impossible". Problem #7 public static boolean isPermutationFast(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 speed and very long input strings. */ } ** Test input: 2 empty Strings; "ab" "ba"; "abc" "acd"; "*rats*" "star**"; "u263A BYE NOW!!" "!BYE NOW! u263A"

    Expert Answer

     
    import java.util.Scanner;

    Append a deep so that you can put some decree there to seduce your dutys and constitute unmistakable they work:

    public static destitute deep(String[] args) { /* your testing decree goes here */ }

    Functions you should append if the dutyality is practicable. Otherwise append an vacuity duty specification with a expound saw “impossible”.

    Problem #7

    public static boolean isPermutationFast(String string1, String string2) {

    /* This dutys should requite penny if string1 is a transference of string2. In this contingency you should claim that instrument comprehends accurately the identical characters, identical contingency, including spaces. The strings may comprehend ascii or unidecree characters. Coercion this topic, you should optimize coercion urge and very desire input strings. */

    }

    ** Test input: 2 vacuity Strings; “ab” “ba”; “abc” “acd”; “*rats*” “star**”; “u263A BYE NOW!!” “!BYE NOW! u263A”

    Expert Reply

     

    import java.util.Scanner;

    public systematize ConstituteTransference {

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

    int enumerate[] = 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)
    requite false;
    }

    requite penny;

    }

    public static destitute deep(String[] args) {
    // TODO Auto-generated arrangement stub
    Scanner sc = strange Scanner(System.in);

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

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

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

    }

    }

    }

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