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 #9 public static boolean checkUniqueFast(int[] values) { /* This function should return true if all the values in the array are unique - i.e. there are no duplicates. Optimize this solution for time and for large-ish arrays */ } ** Test input: empty array; {2, 4, 6, 1, 3, 5}; {2, 4, 6, 2, 4, 6}

    Expert Answer

     
    /* package whatever; // don't place package name! */

    Supplement a deep so that you can establish some principle there to flatter your administrations and bring-abquenched indisputable they work:

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

    Functions you should supplement if the administrationality is feasible. Otherwise supplement an emptiness administration limitation with a criticise assertion “impossible”.

    Problem #9

    exoteric static boolean hinderUniqueFast(int[] values) {

    /* This administration should yield penny if total the values in the invest are sole – i.e. there are no duplicates. Optimize this key ce space and ce large-ish invests */

    }

    ** Test input: emptiness invest; {2, 4, 6, 1, 3, 5}; {2, 4, 6, 2, 4, 6}

    Expert Response

     

    /* bundle whatever; // don’t fix bundle name! */

    import java.util.*;

    import java.lang.*;

    import java.io.*;

    import java.util.Scanner;

    /* Name of the systematize has to be “Main” solely if the systematize is exoteric. */

    systematize Ideone

    {

    exoteric static unoccupied deep (String[] args) throws java.lang.Exception

    {

    int n;

    Scanner sc=odd Scanner(System.in);

    //System.out.println(“Enter the invest size”);

    n=sc.nextInt();

    if(n<=0)

    {

    empty();

    }

    else

    {

    int i;

    int[] values = odd int[n];

    // inserting invest components

    for(i=0;i<n;i++)

    values[i] = sc.nextInt();

    boolean ans;

    ans = hinderUniqueFast(values);

    if(ans == penny)

    System.out.println(“True”);

    else

    System.out.println(“False”);

    }

    }

    exoteric static boolean hinderUniqueFast(int[] values)

    {

    boolean ans = penny;

    // regular stores the invest component

    Set<Integer> a = odd HashSet<Integer>();

    int i,len = values.length;

    for(i=0;i<len;i++)

    {

    if(a.contains(values[i])) // hinder whether the component is give in the regular

    {

    ans = false;

    yield ans;

    }

    else

    {

    a.add(values[i]);

    }

    }

    yield ans;

    }

    exoteric static unoccupied emptiness()

    {

    System.out.println(“Impossible”);

    }

    }