University of Phoenix – DAT/305 – Individual: Sorting, Section 8.9Resource: Ch. 8, “Sorting”, of Data Structures: Abstraction and Design Using Java, Exercises for Section 8.9; Self-Check #1,Complete Self-Check #1 within the “Exercises for Section 8.9” subsection in Section 8.9 “Quicksort” of Ch. 8, “Sorting” in Data Structures: Abstraction and Design Using Java.Submit your assignment to the Assignment Files tab.

University of Phoenix – DAT/305 – Individual: Sorting, Section 8.9Resource: Ch. 8, “Sorting”, of Data Structures: Abstraction and Design Using Java, Exercises for Section 8.9; Self-Check #1,Complete S

Chapter 8 Sorting Chapter Objectives To learn how to use the standard sorting methods in the Java API To learn how to implement the following sorting algorithms: selection sort, insertion sort, Shell sort, merge sort, Timsort, heapsort, and quicksort To understand the difference in performance of these algorithms, and which to use for small arrays, which to use for medium arrays, and which to use for large arrays Sorting is the process of rearranging the data in an array or a list so that it is in increasing (or decreasing) order. Because sorting is done so frequently, computer scientists have devoted much time and effort to developing efficient algorithms for sorting arrays. Even though many languages (including Java) provide sorting utilities, it is still very important to study these algorithms because they illustrate several well-known ways to solve the sorting problem, each with its own merits. You should know how they are written so that you can duplicate them if you need to use them with languages that don’t have sorting utilities. Another reason for studying these algorithms is that they illustrate some very creative approaches to problem solving. For example, the insertion sort algorithm adapts an approach used by card players to arrange a hand of cards; the merge sort algorithm builds on a technique used to sort external data files. Several algorithms use divide-and-conquer to break a larger problem into more manageable subproblems. The Shell sort is a very efficient sort that works by sorting many small sub-arrays using insertion sort, which is a relatively inefficient sort when used by itself. The merge sort and quicksort algorithms are both recursive. Method heapsort uses a heap as its underlying data structure. The final reason for studying sorting is to learn how computer scientists analyze and compare the performance of several different algorithms that perform the same operation. We will cover two quadratic (O(n2)) sorting algorithms that are fairly simple and appropriate for sorting small arrays but are not recommended for large arrays. We will also discuss four sorting algorithms that give improved performance (O(n log n)) on large arrays and one that gives performance that is much better than O(n2) but not as good as O(n log n). Our goal is to provide a sufficient selection of quadratic sorts and faster sorts. A few other sorting algorithms are described in the programming projects. Our expectation is that your instructor will select which algorithms you should study. Sorting 8.1 Using Java Sorting Methods 8.2 Selection Sort 8.3 Insertion Sort 8.4 Comparison of Quadratic Sorts 8.5 Shell Sort: A Better Insertion Sort 8.6 Merge Sort 8.7 Timsort 8.8 Heapsort 8.9 Quicksort 8.10 Testing the Sort Algorithms 8.11 The Dutch National Flag Problem (Optional Topic) Case Study: The Problem of the Dutch National Flag 8.1 Using Java Sorting Methods The Java API java.util provides a class Arrays with several overloaded sort methods for different array types. In addition, the class Collections (also part of the API java.util) contains similar sorting methods for Lists. The methods for arrays of primitive types are based on the quicksort algorithm (Section 8.9), and the methods for arrays of Objects and for Lists are based on the Timsort algorithm (Section 8.7). Both algorithms are O(n log n). Method Arrays.sort is defined as a public static void method and is overloaded (see Table 8.1). The first argument in a call can be an array of any primitive type (although we have just shown int[]) or an array of objects. If the first argument is an array of objects, then either the class type of the array must implement the Comparable interface or a Comparator object must be passed as the last argument (see Section 6.6). A class that implements the Comparable interface must define a compareTo method that determines the natural ordering of its objects. If a Comparator is passed, its compare method will be used to determine the ordering. TABLE 8.1 Methods sort in Classes java.util.Arrays and java.util.Collections Method sort in Class Arrays Behavior public static void sort(int[] items) Sorts the array items in ascending order public static void sort(int[] items, int fromIndex, int toIndex) Sorts array elements items[fromIndex] to items[toIndex] in ascending order public static void sort(Object[] items) Sorts the objects in array items in ascending order using their natural ordering (defined by method compareTo). All objects in items must implement the Comparable interface and must be mutually comparable public static void sort(Object[] items, int fromIndex, int toIndex) Sorts array elements items[fromIndex] to items[toIndex] in ascending order using their natural ordering (defined by method compareTo). All objects must implement the Comparable interface and must be mutually comparable public static

#### Why Choose Us

- 100% non-plagiarized Papers
- 24/7 /365 Service Available
- Affordable Prices
- Any Paper, Urgency, and Subject
- Will complete your papers in 6 hours
- On-time Delivery
- Money-back and Privacy guarantees
- Unlimited Amendments upon request
- Satisfaction guarantee

#### How it Works

- Click on the “Place Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
- Fill in your paper’s requirements in the "
**PAPER DETAILS**" section. - Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
- Click “
**CREATE ACCOUNT & SIGN IN**” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page. - From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.