Write My Paper Button

WhatsApp Widget

please illistrate a UML diagram for the following code bellow, it should have 3 rows, 1…

Homework Help Question & Answers

please illistrate a UML diagram for the following code bellow, it should have 3 rows, 1…

please illistrate a UML diagram for the following code bellow, it should have 3 rows, 1 colum like the one bellow, first box should have the class name, second box is for class attributes, and third box should have the class operations/methods and please put a (+) for public and a (-) for private

example:

class

+-attributes

+-Operations

Also make a JAVADOCs, but not generated by a compiler, to explain what is going on in the code

import java.util.Random;

public class TestClass {
  
public static void main(String[] args) {
  
int bubbleValues[] = new int[20];
int selectionValues[] = new int[20];
int insertionValues[] = new int[20];
int quickValues[] = new int[20];
  
Random input = new Random();
  
for(int i = 0; i bubbleValues[i] = input.nextInt(100);
selectionValues[i] = input.nextInt(100);
insertionValues[i] = input.nextInt(100);
quickValues[i] = input.nextInt(100);
}
  
SortingBenchMarks in = new SortingBenchMarks();
  
int bubbleCount = in.bubbleSort(bubbleValues);
int selectionCount = in.selectionSort(selectionValues);
int insertionCount = in.insertionSort(insertionValues);
int quickCount = in.quickSort(quickValues);
  
System.out.println(“Elements in the bubble array: “);
for(int i =0; i System.out.print(” ” +bubbleValues[i]);
}
System.out.println();
System.out.println(“Elements in the selection array:”);
for(int i = 0; i System.out.print( ” ” +selectionValues[i]);
}
System.out.println();
System.out.println(“Elements in the insertion array:”);
for(int i = 0; i System.out.print( ” ” +insertionValues[i]);
}
System.out.println();
System.out.println(“Elements in the quick array:”);
for(int i = 0; i System.out.print( ” ” +quickValues[i]);
}
System.out.println();
  
System.out.println(“Bubble swaps: ” +bubbleCount);
System.out.println(“Selection swaps: ” +selectionCount);
System.out.println(“Insertion swaps: ” +insertionCount);
System.out.println(“Quick swaps: ” +quickCount);
}

}

=============================================================================================

public class SortingBenchMarks {
  
int bubbleCount = 0;
int selectionCount = 0;
int insertionCount = 0;
int quickCount = 0;
  
public int bubbleSort(int[] array)
{
int maxElement;
int index;
int temp;
  
for(maxElement = array.length – 1; maxElement >=0; maxElement–){
for(index = 0; index if(array[index] > array[index + 1]){
temp = array[index];
array[index] = array[index + 1];
array[index + 1] = temp;
  
bubbleCount += 2;
}
}
}
  
return bubbleCount;
}
public int selectionSort(int[] array) {
  
int strtScan;
int indx;
int minIndx;
int miniValue;
  
for(strtScan = 0; strtScan minIndx = strtScan;
miniValue = array[strtScan];
  
for(indx = strtScan + 1; indx if(array[indx] miniValue = array[indx];
minIndx = indx;
}
  
}
  
array[minIndx] = array[strtScan];
array[strtScan] = miniValue;
  
selectionCount += 2;
}
return selectionCount;
}
  
public int insertionSort(int[] array){
int unsortedValue;
int scan;
  
for(int index = 1; index unsortedValue = array[index];
scan = index;
  
while(scan > 0 && array[scan – 1] > unsortedValue){
array[scan] = array[scan – 1];
scan–;
insertionCount++;
}
  
array[scan] = unsortedValue;
insertionCount++;
}
return insertionCount;
}
  
public int quickSort(int array[]){
  
doQuickSort(array, 0, array.length – 1);
return quickCount;
}
  
private void doQuickSort(int array[], int start, int end){
  
int pivotPoint;
  
if(start pivotPoint = partition(array, start, end);
doQuickSort(array, start, pivotPoint – 1);
doQuickSort(array, pivotPoint + 1, end);
}
}
  
private int partition(int array[], int start, int end){
  
int pivotValue;
int endOfLeftList;
int mid;
  
mid = (start + end) / 2;
swap(array, start, mid);
pivotValue = array[start];
endOfLeftList = start;
  
for(int scan = start + 1; scan if(array[scan] endOfLeftList++;
swap(array, endOfLeftList, scan);
}
}
  
swap(array, start, endOfLeftList);
return endOfLeftList;
}
  
private void swap(int[] array, int a, int b){
int temp;
temp = array[a];
array[a] = array[b];
array[b] = temp;
  
quickCount += 2;
}

}

0 0
Add a comment
Don`t copy text!
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
???? Hi, how can I help?