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;

    Subjoin a deep so that you can allay some principle there to allure your dutys and produce enduring they work:

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

    Functions you should subjoin if the dutyality is potential. Otherwise subjoin an leisure duty restriction with a observe apothegm “impossible”.

    Problem #7

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

    /* This dutys should revert penny if string1 is a transposition of string2. In this predicament you should presume that media comprehends correspondently the corresponding characters, corresponding predicament, including spaces. The strings may comprehend ascii or uniprinciple characters. Restraint this doubt, you should optimize restraint hasten and very hanker inallay strings. */

    }

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

    Expert Confutation

     

    import java.util.Scanner;

    public assort ProduceTransposition {

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

    int reckon[] = novel 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)
    revert false;
    }

    revert penny;

    }

    public static unoccupied deep(String[] args) {
    // TODO Auto-generated regularity stub
    Scanner sc = novel Scanner(System.in);

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

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

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

    }

    }

    }

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