1. Implement a method called bubbleSort, that takes an ArrayList, sorts it using bubble sort algorithm, and returns a sorted list,

2. Implement a method called selection Sort, that takes an ArrayList, sorts it using selection sort algorithm, and returns a sorted list;

3. Implement a method called insertion Sort, that takes an ArrayList, sorts it using insertion sort algorithm, and returns a sorted list:

4. Implement a method called mergeSort, that takes an ArrayList, sorts it using merge sort algorithm, and returns a sorted list.

Part 2:

1. Test the methods. Create a random array list with 10000 elements. Use the following: ArrayList arrayRandom = new ArrayList(10000); Random rand = new Random(); rand.setSeed(System.currentTimeMillis()); for (int i=0; i<10000; i++) Integer r = rand.nextInt() % 256; arrayRandom.add(r);

2. Calculate how much time it takes for each method to sort the list. (Use "System.currentTimeMillis()" method to get current time in milliseconds.).

3. Compare method execution time and determine which method did the best. Which method is the fastest? Why?

Solved
Show answers

Ask an AI advisor a question