程序代写代做 graph algorithm Java Lab 4.2 – Sorting

Lab 4.2 – Sorting

1. Show the steps of sorting the integers 23, 48, 11, 3, 79, 35, 7, 19 by using

i. Selection sort
ii. Bubble sort
iii. Insertion sort
iv. Merge sort
v. In-Place Quick sort (with 1st element as pivot) *refer to Appendix I

2. Show the steps for sorting the integers 79, 48, 35, 23, 19, 11, 7, 3 by using the above five methods.

3. Fill in the following table:

Performance (# of comparisons)

with original data (in O-notation)

Sorting algorithms

Data is in random order

Data is in ascending order(Guess)

Data is in descending order

In place? (yes or no)
Selection
O(n2)

O(n2)
O(n2)
yes
Bubble

Insertion

Merge

Quick

,

4. [Bubble Sort] Implement the bubble sort algorithm in Java. The program skeleton is given below:

public class BubbleSort {
public static void main(String [ ] args) {
int [ ] arr = {21, 13, 8, 42, 19, 5, 34, 61};
bubbleSort(arr);

for (int i=0; i Post navigation