Java Sorting Algorithm (1): Overview, java Sorting Algorithm Overview
Java Sorting Algorithm (I) Overview
Sorting is a very common operation in program development. After sorting an arbitrary set of data elements (active records, you can turn them into a set of ordered sequences sorted by keywords.
For a sorting algorithm, the advantages and disadvantages of the algorithm are generally measured in the following three aspects.
1. Time Complexity: It mainly analyzes the comparison times of keywords and the moving times of records.
2. spatial complexity: analyze how much auxiliary memory is needed in the Sorting Algorithm
3. Stability: if the key values of record A and record B are the same, the order of the key values of record A and record B remains unchanged. This sorting algorithm is stable. The opposite is unstable.
Internal sorting: According to the existing sorting algorithms, sorting can be roughly divided into internal sorting and external sorting. If the entire sorting does not require external memory (such as disks), all sorting is completed in the memory. This sort is called internal sorting.
External sorting: If there are a large number of data elements involved in sorting, the entire sorting process cannot be completed in the memory by means of external memory (such as disk ), this sort is called external sort.
Common internal sorting can be divided into the following categories:
1. Select sorting (directly select sorting and heap sorting) |
Ii. Exchange sorting (Bubble sorting and quick sorting) |
3. Insert sorting (insert sorting directly, semi-insert sorting, shell sorting) |
Iv. Merge Sorting |
V. Sort buckets |
6. Base sorting |