Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, can anyone please help me with this one.I am almost finish but still struggl

ID: 3618606 • Letter: H

Question

Hi, can anyone please help me with this one.I am almost finish but still struggle for adding something. Thereare two files. first one "Class bubblesort"- this is correct andnext Test bubble sort all run correct.

And my professor said , "How many comparisons are required to putthe following arrays in ascending order using the Merge Sort?

A [] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
B[] = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
C [] = {set of 16 random numbers}
"






// Generic BubbleSort

class BubbleSort<T>
{
    T List[];
  
    public BubbleSort( T arrayX[])
    {
        List = arrayX;
        BubbleSort();
        displayArray();
    }
  
    public void BubbleSort()
    {
        int n = List.length - 1,pass = 0;
        boolean changed =true;
        do
           {
               changed = false;
               for( int j = 0; j < n- pass; j ++)
                   if(( (Comparable)List[j]).compareTo(List [j+1]) > 0)
                   {
                       T temp = List[j];
                       List[j] = List[j+1];
                       List[j+1] = temp;
                       changed = true;
                   }
               pass ++;
           }
           while (changed);
        }
      
        public voiddisplayArray()
        {
           System.out.println();
           for ( int k = 0; k < List.length; k++)
               System.out.print(List[k] + " ");
           System.out.println();
        }
    }
   

--------------------------------------------------------------------------

// Test BubbleSort


class TestBubbleSort
{
    public static void main(String []args)
    {
        Integer List[] = { 20,10, 15, 5, 13, -5, 3, 7, 13, -50};
      
        // add from whiteboard
        Double ListS[] = {10.5,7.3, 3.14, -7.8, 9.4, 3.29, -1.2, 0.5};
      
      
       BubbleSort<Integer> B = newBubbleSort<Integer>(List);
      
        // add
        BubbleSort<Double>C = new BubbleSort<Double>(ListS);
      
        String Cities[] ={"Boston", "Anaheim", "San Francisco", "Saint Louis",
                                "New York", "Chicago", "Dallas"};
        BubbleSort<String>D = new BubbleSort<String> (Cities);
       System.out.println();
    }
}


---------------------------------------------------------------------------------------

Thanks!!



Explanation / Answer


C [] = {set of 16 random numbers}
n * log(n) = 44, worst case

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote