CMPT 125/6 Lab 4

  1. Create a class CreateArray that contains the following methods:
    1. The Random class can be instantiated to create an object that will generate (pseudo-)random values. Create a method randomArray:
      public static int[] randomArray(int n) { … }

      This method should return an array filled with n randomly generated integers.

    2. Create a method sortedArray:
      public static int[] sortedArray(int n) { … }

      This method should return an array filled with n randomly generated integers that are in increasing order. Hint: call your function from (a) and then sort the result.

  2. Create a text file runningtime.txt that contains answers to the following:
    1. What is the running time of the randomArray method you created above? Briefly explain why.
    2. What is the running time of the sortedArray method you created above? Briefly explain why.
  3. Create a text file named time.txt. In it, indicate how long it took you to complete this lab exercise.

When you're done, create a ZIP file containing all of the files you created for this lab and submit it with the submission server.