public class Directrank {public static void Main (string[] args) {Directrank aa=new Directrank ();try {Aa.judge (args);} catch (Testdefinexception E2) {E2.printstacktrace ();}Integer[] A=new integer[args.length];try{for (int i=0;i{System.out.print (args[i]+ "");A[i]=a[i].parseint (Args[i]);//Convert the read-in string type to Intgr}System.out.println ();}catch (NumberFormatException e){System.out.println ("\ n input data is incorrect \ n");}catch (NullPointerException E1){e1.getmessage ();}Aa. R
Text descriptionAnd the direct insert sort comparison, just the "find" operation using "binary find" to implement, the insertion sort is called binary insert sort.SlightlyAlgorithm analysisand the direct insertion sort ratio, reduces the number of comparisons, but the number of moves has not changed, so the time complexity of binary insertion sorting algorithm is
Bubble sort: This is a good understanding of two two, and the code is better written.Its principle is the adjacent two two comparison, if the previous number is larger than the back, then the exchange, it can be compared to a time when the maximum number of a single, and then loop, each outer loop within the number of cycles less than the original. #region Bubble Sort 2// list[j + 1] = temp;18
Here we introduce some of the commonly used sorting methods, sorting is a programmer's basic skills, so-called sorting is a set of data, in a certain order of the process.Charging efficiency lookBubble sorting Internal sorting methodExchange-Type sorting methodBubbling methodBasic idea:Bubble Sort MethodCase:
123456789101112131415161718192021st2223242526
Simple.$arr =array (0,5,-1);Now let's wrap the function as a function and use
The process of bubbling sorting is to first compare the keywords of the first record with the keywords of the second record, and, in reverse order, Exchange two records and then compare the keywords for the second record and the third record. And so on, until the n-1 record and the nth record's keywords have been compared. The above process is called the first bubbling sort, then the second trip to the previous n-1 the same operation, ...The quick
First, overview: The previous blog describes common simple algorithms: bubble sort, select sort, and insert sort. This article describes the Advanced sorting algorithm: Quick sort and merge sort. Before we begin to introduce the algorithm, we first introduce the basic knowl
>>> a = [1,3,6,7,4]>>> >>> sorted(a)[1, 3, 4, 6, 7]>>> >>> a.reverse()>>> a[4, 7, 6, 3, 1]>>> >>> sorted(a)[::-1][7, 6, 4, 3, 1]>>> a [4, 7, 6, 3, 1]>>> >>> >>> a.sort()>>> a[1, 3, 4, 6, 7]>>> The difference between sort and sorted1, sort is the original list in situ, sorted is a new list2. Sorted is valid for all iteration sequences and can be arranged in a dictionaryThe difference between sorted and
Basic idea:In the set of numbers to be sorted, the total number in the range that is not currently in sequence, the top-down pairs of adjacent two numbers are compared and adjusted sequentially, so that the larger number to sink , smaller upward. That is, each time a comparison of two adjacent numbers finds that they are in the opposite order of order, they are interchanged. Algorithm implementation: (HDU 1040 pro-Test AC)#include using namespacestd;Const intN =1005;voidBubblesort (intA[],int );
These three sorts, while not very useful, and inefficient, but they are stable sorting algorithm, and easy to confuse, this gives the implementation code to help readers distinguishFirst, insert sort1#include 2 using namespacestd;3 Const intmaxn=1000005;4 intN;5 intA[MAXN];6 voidInsert_sort (int*a)7 {8 for(intI=2; i)9 {Ten inttmp=A[i]; One intj=i-1; A while(j>=0tmpA[j]) - { -a[j+1]=A[j]; thej--; - } -a[j+1]=tmp; - } + } - intMain () + { AStd:
1. Direct Ordering: public static void selectsort (int [] arr) {
for (
int x = 0; x for (int y = x + 1; y if (Arr[x] > Arr[y]) { int temp = Arr[x] ; ARR[X] = Arr[y]; Arr[y] = temp; } } } }
Description: Double for loop, the first number of the array a[0] and all subsequent numbers are compared, get the smallest number, and then the second number a[1] and all the subsequent numbers are compared
Sort: bubble sort vs Quick Sort, bubble sort
In the process of development, we often encounter set sorting. In general, we use list. the OrderBy () method does not need to be concerned with the implementation of the algorithm. in the past few days, I am going to review the data structure and algorithms.
First, let's ta
First, bubble sort:
1, Algorithmic thinking:
For the data to be sorted, compare the two adjacent numbers from top to bottom and adjust them, moving the largest number downward and the smaller number upward. That is: Each trip compares adjacent two data elements in turn, placing the smaller numbers on the left, looping the same operation until all the data elements to be sorted are finished.
2. Example Analysis:
For example: We have to stand in a row o
The following articles mainly describe the correct steps for DB2 backup and cross-platform migration. If you are curious about the correct steps for DB2 backup and cross-platform migration, the following articles will unveil its secrets. The following is a detailed description of the article. I hope you can learn from it.
Database, backup, DB2, cross-platform mig
In browsing the forum posts, found that many students suffer from not having some "tips", so have to put down the work to check the data, the results found out, just the idea of a meaningful and no. Now sort out some tips to help people in need. Let's start with the DB2.
1. View the Local node directory
Command Window ENTER: DB2 list node Directory
2. Catalogi
Bubble Sort :The data in the array, in turn, compares the size of the adjacent two numbers.If the previous data is larger than the subsequent data, the two numbers are exchanged.Time complexity O (n^2)1 functionBubble (array) {2 vartemp;3 for(vari=0; i){4 for(varj=0; j){5 if(arr[j]>arr[j+1]){6temp = arr[j+1];7ARR[J+1] =Arr[j];8arr[j]=temp;9 }Ten }console.log (arr); One } A}//Bubble SortSelect Sort:First se
Strategizing DB2-transforming from Oracle O M (the first choice for database O M workers)Basic InformationAuthor: Wang feipeng Wang fuguo Liu xusun Yue [Translator's introduction]Series name: dancing DB2 SeriesPress: Electronic Industry PressISBN: 9787121177439Mounting time:Published on: February 1, August 2012Start: 16Page number: 480Version: 1-1Category: ComputerMore about "" and "strategizing
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.