Question

In: Computer Science

randomGenotype() create a valid genotype of size 12, using random values valid genotype contains each of...

randomGenotype()

  • create a valid genotype of size 12, using random values
  • valid genotype contains each of the numbers 1 to 12 exactly once

HERE IS THE CODE

_____________________________________________________________________________________________________________________________________________________

public static Integer [] randomGenotype()
{
    Integer [] genotype = new Integer [boardSize];

    // YOUR CODE GOES HERE
    // DUMMY CODE TO REMOVE:
    genotype = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
    // END OF YOUR CODE

    return genotype;
}

Solutions

Expert Solution

import java.util.Random;
public class RandomNum {
   public static void main(String args[])
   {
       int[] array=randomGenotype();
       for(int i=0;i<12;i++)
           System.out.print(array[i]+" ");
   }
   public static int [] randomGenotype()
   {
   int [] genotype = new int [12];
   Random rand = new Random();
   int num ;
   int i=0;
  
   do
   {
       num = rand.nextInt(100);
       int c=1;
       for(int j=0;j<genotype.length;j++)
       {
           if(genotype[j]==num)
           {
               c=0;
               break;
           }
       }
       if(c==1)
       {
           genotype[i]=num;
           i++;
       }
       else
       {
           continue;
       }
   }while(i<12);

   // YOUR CODE GOES HERE
   // DUMMY CODE TO REMOVE:
   //genotype = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
   // END OF YOUR CODE

   return genotype;
   }
}


Related Solutions

Question 1 contains the actual values for 12 periods (listed in order, 1-12). In Excel, create...
Question 1 contains the actual values for 12 periods (listed in order, 1-12). In Excel, create forecasts for periods 6-13 using each of the following methods: 5 period simple moving average; 4 period weighted moving average (0.63, 0.26, 0.08, 0.03); exponential smoothing (alpha = 0.23 and the forecast for period 5 = 53); linear regression with the equation based on all 12 periods; and quadratic regression with the equation based on all 12 periods.  Round all numerical answers to two decimal...
Based on the calculated values of Kc for each reaction stoichiometry, which reaction is the valid...
Based on the calculated values of Kc for each reaction stoichiometry, which reaction is the valid one? Fe(aq)3+ + SCN(aq)- FeSCN(aq)2+ The average value of Kc: 369.10 Fe(aq)3+ +2 SCN(aq)- Fe(SCN)2(aq)+ The average value of Kc: 988999.02 Briefly explain your conclusion. Compare the percent difference between the average value and the individual measurements. What does this tell you about the two possible stoichiometries? Do these reactions give consistent values of Kcfor different initial reaction conditions?
A bag contains 12 balls of the same shape and size. Of these, 9 balls are...
A bag contains 12 balls of the same shape and size. Of these, 9 balls are blue, and the remaining 3 balls are red. Suppose that you do the following iterative random experiment: In each iteration, 5 balls are removed randomly (without replacement) from the bag, in such a way that any 5 balls in the bag are equally likely to be the 5 balls that are removed. After doing this, you check whether among the 5 removed balls there...
Research the topics thoroughly using valid, reliable sources. 2-Each student will prepare an 8-12 page research...
Research the topics thoroughly using valid, reliable sources. 2-Each student will prepare an 8-12 page research paper (2-3 pages for each question): double-spaced, Times New Roman and 12-point font. 3-Originality is a “must” in research. Therefore, use your own words when answering questions - DO NOT copy text from your book or any other source. Copied answers will result in a zero on this assessment. 4-Use references, if needed. Please use APA format when citing sources. OB = Organization Behavior...
Research the topics thoroughly using valid, reliable sources. 2-Each student will prepare an 8-12 page research...
Research the topics thoroughly using valid, reliable sources. 2-Each student will prepare an 8-12 page research paper (2-3 pages for each question): double-spaced, Times New Roman and 12-point font. 3-Originality is a “must” in research. Therefore, use your own words when answering questions - DO NOT copy text from your book or any other source. Copied answers will result in a zero on this assessment. 4-Use references, if needed. Please use APA format when citing sources. OB = Organization Behavior...
Research the topics thoroughly using valid, reliable sources. 2-Each student will prepare an 8-12 page research...
Research the topics thoroughly using valid, reliable sources. 2-Each student will prepare an 8-12 page research paper (2-3 pages for each question): double-spaced, Times New Roman and 12-point font. 3-Originality is a “must” in research. Therefore, use your own words when answering questions - DO NOT copy text from your book or any other source. Copied answers will result in a zero on this assessment. 4-Use references, if needed. Please use APA format when citing sources. OB = Organization Behavior...
A block of memory contains 40 random words of data. Assume that the values are in...
A block of memory contains 40 random words of data. Assume that the values are in two’s complement representations and are stored in the Read/Write memory area. You need to provide the 40 random words and to include them in an initialization file: assign.ini. Write a program using the ARM assembly programming language to do the following: a) You are required to reverse the word order in a block of 40 random words (Hint: the last word stored in the...
create a function that sorted tuple by the second values of each tuple. If the values...
create a function that sorted tuple by the second values of each tuple. If the values are the same, sorted by increasing order. Finally returns a list of the first element of each tuple that sorted. def sort_tup(tup): #Code here input : tup1 = [(1, 15), (2, 8), (3, 22), (4, 30), (5, 15)] output: [4,3,1,5,2]
a) If random samples of size 12 are drawn from a population with mean 7 and...
a) If random samples of size 12 are drawn from a population with mean 7 and standard deviation 2 , find the standard error of the distribution of sample means. b) Assume the sample is a random sample from a distribution that is reasonably normally distributed and we are doing inference for a sample mean. Find endpoints of a t-distribution with 0.025 beyond them in each tail if the sample has size n=26. c) Assume the sample is a random...
Suppose a random sample of size 51 is selected from a population with = 12. Find...
Suppose a random sample of size 51 is selected from a population with = 12. Find the value of the standard error of the mean in each of the following cases (use the finite population correction factor if appropriate). a. The population size is infinite (to 2 decimals). b.The population size is N = 50,000 (to 2 decimals). c. The population size is N = 5,000 (to 2 decimals). d.The population size is N = 500 (to 2 decimals).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT