eclipse - Converting bad Pseudo code to Java -


OK, I have two pieces of pseudo code, which should be converted to a Java code, except not very good And I said, 'It is rarely good whenever its good .. Anyway I was hoping someone could help.

Here is the first bit of pseudo code:

  1. Make a random integer that is between 0 and n-1.
  2. Create empty New string is called x.
  3. Copy elements from 0 to P1 from Scassel to X.
  4. Copy the changed version of the string scassol to p to the X.
  5. Copy of N-1's Scansol from P + 1 to X.
  6. Set up Scassol to be x.

    And here's the code, away (I originally did the first two steps but after that I got stuck):

      Public Zero SmallChange () {Random rand = new random (); Rand.setSeed (System.currentTimeMillis ()); Int n = scasol.length (); Int p = Math.abs (rand.nextInt ()% n); String x; If (n   

    this is the second piece of code that I can not convert to Java (I have not done anything for it yet I completely stumped):

    1. We need to add for that loop which iterates for the number of iterations of the specified number.
    2. We need to make the initial random solution of size n.
    3. We need to evaluate the fitness of our current solution within the loop.
    4. We need to copy the current solution (old says).
    5. We make a small change to evaluate the current solution and fitness in any other variable.
    6. If the new fitness is worse than the old, then we copy the old solution back to our existing solution.
    7. Upon completion we can return the current solution.

      The second problem is to complete a small change, while the other is to make a random intensity hill climbing algorithm, but yes the word is not stuck I hope someone can help you, I appreciate any help because I am trying to do this for days! The first bit of pseudocode says:

      Enter It is not clear what is the statement of "changed version"?

      Putting a character in the string is a simple task in Java.
      See

      The second piece of pseudocold is a dire requirement for reference and explanation.

      / div>

Comments