Lehigh University**We aren't endorsed by this school
Course
CSE 17
Subject
Computer Science
Date
Dec 17, 2024
Pages
4
Uploaded by DoctorElectron15867
CSE017Lehigh UniversityFall 2024Programming and Data StructuresActive Learning Activity 11: Sorting AlgorithmsActivity ObjectivesAt the end of this activity, students should be able to:1.Modify the sorting algorithms seen in class to make them generic2.Modify the sorting algorithms seen in class to sort array lists3.Compare the performance of the sorting algorithms for three different data setsActivity1.Modify the classSortto make the first six sorting algorithms generic and the eightalgorithms accept an array list as a parameter, instead of an array. The signatures of theeight sorting algorithms are provided below.a.Selection Sortpublic static <E extends Comparable<E>>voidselectionSort(ArrayList<E> list)b.Insertion Sortpublic static <E extends Comparable<E>>voidinsertionSort(ArrayList<E> list)c.Bubble Sortpublic static <E extends Comparable<E>>voidbubbleSort(ArrayList<E> list)d.Merge Sortpublic static <E extends Comparable<E>>voidmergeSort(ArrayList<E> list)e.Quick Sortpublic static <E extends Comparable<E>>voidquickSort(ArrayList<E> list)f.Heap Sortpublic static <E extends Comparable<E>>voidheapSort(ArrayList<E> list)g.Bucket Sortpublic static voidbucketSort(ArrayList<Integer> list)h.Radix Sortpublic static voidradixSort(ArrayList<Integer> list)
CSE017Lehigh UniversityFall 2024FormergeSort, define an additional methodsubListto split the list into twohalves:firstHalfandsecondHalf.public static <E> ArrayList<E> subList(ArrayList<E> list,int start, int end)The method returns an array list with a copy of the elements from indexstartto indexend-1.1.In a test program, create an array list of 10,000 integers and fill it with random numbersbetween 0 and 9,999 inclusive. Name the array listrandomList.2.CreatetwocopiesofrandomListusingtheclonemethodfromtheclassArrayList. Name the two copiessortedListandreversedList. Sort the twoclone lists using the methodsortfrom the classjava.util.Collections. Thenreversethesecondlistusingthemethodreversefromtheclassjava.util.Collections.3.Sort the three array lists using the different sorting algorithms from the classSort.Display the number of iterations of each sorting algorithm for each list.Do not forgetto shufflerandomListand reversereversedListbefore calling the next sortingalgorithm. Use the methodshufflefromjava.util.Collections.4.Display the results as a table similar to the output below. Discuss the performance ofeach sorting algorithm for random, sorted, and reversed datasets. Then compare theeight algorithms to each other for the three datasets. Include your discussion in the testclass as a multiline comment.5.Submit the Java filesSort.javaandTest.javaon Github.
CSE017Lehigh UniversityFall 2024The following rubric is used for grading:Learning OutcomeHow is the outcomeachieved?PointsImplement a version of thesorting algorithms that is genericand sorts an array listMethods for the eight sortingalgorithmsSelection sortInsertion sortBubble sortMerge sortQuicksortHeap sortBucket sortRadix sort80 pts10 pts/eachTest the eight algorithms onthree different data sets(random, sorted, reversed lists)Class Test (main method)10 ptsCompare the performance of thesorting algorithmsDiscussing the results obtained foreach algorithm and comparing thealgorithms to each other10 ptsTotal100 pts