movementFeatures: Data movement is minimal, unstable, suitable for use when the number of sorts is less PackageCn.guangboyuan;Importjava.util.Arrays;/** * @authorRed Ants * Public number: Programmer's Way * Select Sort*/ Public classSelectionsort { Public Static int[] Selectionsort (int[] ints) { inttemp; intRunnum = 0; for(inti = 0; i ) { for(intj = i+1; J ) { if(ints[j]Ints[i]) {Temp=Ints[i]; Ints[i]=Ints[j]; INTS
The example in this article describes how Java uses a bubble sort array to sort the arrays. Share to everyone for your reference. Specifically as follows:
First, bubble sort:
Sort arr
/** * Bubble Sort estimation is a sort method that is mentioned in every algorithm book.
* Its basic idea is to the length of the sequence of N, with N trip to arrange it into an ordered sequence.
* The 1th trip will be the largest elements in the sequence of the tail, the 2nd trip will be the 2nd large elements in the penultimate position, * that is, each ti
1. Use the sort () in the arrays class in the Javaapi document to sort quickly
Copy Code code as follows:
Import Java.util.Arrays;
public class testone{
public static void Main (String [] args) {
int [] array={2,0,1,4,5,8};
Arrays.sort (array);//Call Arrays static method sort, sorted in ascending order
for (int show:array) {
Sy
This article illustrates the bubbling sort of Java sort algorithm summary. Share to everyone for your reference. The specific analysis is as follows:
Bubble Sort (bubblesort) is to compare the adjacent two numbers sequentially, place the decimal number in the front, and th
}} 3. Quick Sort provides method invocation/** * Quick sort @param numbers with sorted array */ void Quick (int// view array is empty {quickSort (numbers, 0, numbers.length-1);}} Analysis:Fast sorting is generally considered to be the best average performance in a sorting method of the same order of magnitude (O (nlog2n)) . However, if the initial sequence is ordered or basically
1 、-------MessageFor beginners of Java students, the sort is in a strange but a basic problem. But because I have just stepped into the world of learning Java, a lot of things can not be well understood, resulting in their own can be knocked out of code or roughly to understand,But the idea of solving the problem is not very well in depth. (In fact, the beginning
before the large number is placed;Then compare the 2nd and 3rd numbers, put the decimal before the large number, so continue until the last two numbers are compared, the decimal place before the large number of places;At the end of the first trip, the largest number was put to the last.On the second trip:The comparison is still started from the first logarithm (because the 1th number is no longer less than the 2nd number because of the 2nd and 3rd number of interchanges), the decimal place is p
Preface: About the Bubble sort and choose the sort, each time writes the time to look at their concept again, this time, writes oneself to understand1. Bubble Sort:In fact, bubble sort should be proved by example, set the array le
item is placed in the position of the previous item, the second round selects the third item as the insert item and then the second item is removed The second item is moved back to the insert item, and then inserted as compared to the first item if small, then the first item is moved to the second item, the insert item is placed in the first item, and so on.These three kinds of sorted Java programs1. Bubble
] = arr[j+1];ARR[J+1] = temp;}}}}}Of course, Java can also be quick to sort, but it is recommended that you do not write fast sorting, because Java provides a lot of class library, the direct call on the line to save a lot of writing code necessary. For the sort method, call the so
1. Bubble sortBubble sort (Bubble sort) is one of the most classic and simplest sorting algorithms.Principle: Compare two adjacent elements, Exchange large value elements to the right (descending opposite).Step: Compare adjacent elements. If the first one is bigger than the second one, swap them both. Do the same for e
Code:1 Packagecom.cn.algorithm_arithmetic algorithm;2 /**3 * This program records the bubble sort of the classical sorting algorithm4 * @authorAdministrator5 *6 */7 8 Public classBubble_sort {9 //bubble sort before optimizationTen Public Static voidBubble_sort (int[] a) { One for(inti = 0
The bubbling sort is each traversal. The adjacent numbers are compared, the former is larger than the latter, and the maximum value is shifted back to the last position; The key point of the algorithm is to determine the boundary of each cycle;The following two algorithms are a certain degree of improvement to bubble sort, but the
Java Select sort and Bubble sort1.datasorter.javapublic class Datasorter {//Bubble sort method//main idea: Sort by ascending order, array element 22 comparison, large immediately after public static void Bubblesort (int[] a) {for
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.