The second definition of an array
Array-Traversal
The core idea of array operation is the operation of diagonal mark;
Array-Find the most value
1. Cycle comparison
Sort
Select Sort to split the original array into two arrays, at least one is ordered
Bubble sort adjacent elements comparison
Location Substitution Code Extraction
Formal parameters
Sorting performance issues
Select Sort, and each wheel finds the minimum value before swapping a position
Find
Traverse to compare the value to find, no return-1
Binary find (binary search)
Prerequisites: Elements within an array are unique and orderly
Cyclic judging conditions are: intermediate value judgment;
"/2" relative to ">>1"
Returns the insertion point directly (-insertion point-1) If the found element does not exist
1 Public Static intBinarySearch (int[]arr,intkey) {2 intStart = 0;3 intEnd = Arr.length-1;4 intMid = (start+end)/2;5 while(end>start) {6 if(key==Arr[mid]) {7 returnmid;8 }9 Else if(key>Arr[mid]) {TenStart = Mid+1; One}Else{ AEnd=mid-1; - } -Mid = (start + end)/2; the } - return-1; -}
Binary conversion
Convert to 16 binary--with Operation &15, unsigned right shift >>>4
(char) temp-10+ ' A '
Using Arrays--table-checking method
1 Public StaticString Trans (intNumintBaseintoffset) {2 Char[] CHS ={' 0 ', ' 1 ', ' 2 ', ' 3 ',3' 4 ', ' 5 ', ' 6 ', ' 7 ',4' 8 ', ' 9 ', ' A ', ' B ',5' C ', ' D ', ' E ', ' F '};6String ss= "";7 while(true){8 inttemp = num &Base;9ss= chs[temp]+SS;Tennum = num >>>offset; One if(num==0) A returnSS; - } -}
Integer.tobinarystring ()
Java Day 05