Sorting algorithms are good examples for studying algorithm design and analysis. Sorting is a classic subject in computer science. There are three reasons to study sorting algorithms.
The data to be sorted might be integers, doubles, characters, or objects. Section, Sorting Arrays, presented selection sort. The selection sort algorithm was extended to sort an array of objects in Section, Case Study: Sorting an Array of Objects. The Java API contains several overloaded sort methods for sorting primitive type values and objects in thejava.util.Arraysandjava.util.Collectionsclasses. For simplicity, this chapter assumes:
The programs can be easily modified to sort other types of data, to sort in descending order, or to sort data in anArrayListor aLinkedList.
There are many algorithms for sorting. You have already learned selection sort. This chapter introduces insertion sort, bubble sort, merge sort, quick sort, bucket sort, radix sort, and external sort.
The above is the detailed content of Sorting. For more information, please follow other related articles on the PHP Chinese website!