Creating 1000 arrays and sorting them using the bubble and selection sort (C#) : <p>I am new to programming. C# is my first programming language. </p>

<p>I have an assignment where I have to create and test out a bubble sort algorithm and a selection sort algorithm using arrays. I think I understand those now. </p>

<p>The next part of the assignment I am having some trouble on. </p>

<p>I have to write a program that will ask the user for a number (n) and create 1000 arrays of n size. </p>

<p>So if the user enters 5 for the number, my program has to <em>create and sort</em> 1000 arrays that are of length 5. </p>

<p>I have to use the bubble sort and the selection sort methods I created. </p>

<p>After I do that, I have to initiate a variable called <em>running_time</em> to 0. I have to create a for loop that iterates 1000 times and in the body of the loop i have to create an array of n random integers. </p>

<p>Then I have to get the time and set this to the start time. My professor said to notice that the sort is started after each array is built, so I should time the sort process only. </p>

<p>Then I have to get the time and set it to end time. I have to subtract the start time from end time and add the result to the total time.</p>

<p>Once the program has run, note 
1. the number of items sorted
2. the average running time for each array (total time/1000)</p>

<p>Then I have to repeat the process using 500, 2500, and 5000 as the size of the array. </p>

<p>This is my code for creating one array with n number of spaces and filled with random integers. </p>

<pre><code>//Asks the user for number
        Console.WriteLine("Enter a number: ");
        n = Convert.ToInt32(Console.ReadLine());

        //Creates an array of the length of the user entered number
        int[] randArray = new int[n];

        //Brings in the random class so we can use it.
        Random r = new Random();

        Console.WriteLine("This is the array: ");

//For loop that will put in a random number for each spot in the array. 
        for (int i = 0; i &lt; randArray.Length; i++) {
            randArray[i] = r.Next(n);
            Console.Write(randArray[i] + " ");
        }
        Console.WriteLine();
</code></pre>

<p>THIS IS MY CODE FOR THE BUBBLE SORT ALGORITHM:</p>

<pre><code>//Now performing bubble sort algorithm:
        for (int j = 0; j &lt;= randArray.Length - 2; j++) {
            for (int x = 0; x &lt;= randArray.Length - 2; x++) {
                if (randArray[x] &gt; randArray[x + 1]) {
                    temp = randArray[x + 1];
                    randArray[x + 1] = randArray[x];
                    randArray[x] = temp;
                }
            }
        }

//For each loop that will print out the sorted array
        foreach (int array in randArray) {
            Console.Write(array + " ");
        }
        Console.WriteLine();
</code></pre>

<p>THIS IS MY CODE FOR THE SELECTION SORT ALGORITHM:</p>

<pre><code>//Now performing selection sort algorithm
        for (int a = 0; a &lt; randArray1.Length - 1; a++) {
            minkey = a;
            for (int b = a + 1; b &lt; randArray1.Length; b++) {
                if (randArray1[b] &lt; randArray1[minkey]) {
                    minkey = b;
                }
            }
            tempSS = randArray1[minkey];
            randArray1[minkey] = randArray1[a];
            randArray1[a] = tempSS;
        }

//For loop that will print the array after it is sorted.
        Console.WriteLine("This is the array after the selection sort algorithm.");
        for (int c = 0; c &lt; randArray1.Length; c++) {
            Console.Write(randArray1[c] + " ");
        }
        Console.WriteLine();
</code></pre>

<p>This is very overwhelming as I am new to this and I am still learning this language. </p>

<p>Can someone guide me on the beginning on how to create 1000 different arrays filled with random numbers and then the rest. I would appreciate it greatly. Thank you. </p>
