## ## 当前位置：首页 > 百利宫信誉 > 百利宫信誉

### 基础查找算法（顺序无序查找算法和递归二叉查找算法）

#### 时间：2020-03-23本站浏览次数：109

1、顺序查找的一般实现：

public static int SqSearch(int[] source, int target){ for (int i = 0; i < source.Length; i++) { if (source[i] == target) { return i; } } return -1;}

public static int FindMax(int[] source){ int max=source; for(int i=1;i<source.Length;i++){ if(max<source[i]){ max=source[i]; } } return max;}

public static int FindMin(int[] source){ int min = source; for (int i = 1; i < source.Length; i++) { if (source[i] < min) { min = source[i]; } } return min;} public static int Hot20SqSearch(int[] source, int target){ for (int i = 0; i < source.Length; i++) { if (source[i] == target) { if (i > source.Length * 0.2) { var temp = source; source = source[i]; source[i] = temp; } return i; } } return -1;}

public static int HotSwapSqSearch(int[] source, int target){ for (int i = 0; i < source.Length; i++) { if (source[i] == target) { if (i > 0) { var temp = source[i-1]; source[i-1] = source[i]; source[i] = temp; } return i; } } return -1;}

public static int BinSearch(int[] source, int target){ int left = 0, right = source.Length-1,middle; while (left <= right) { middle = (left + right) / 2; if (source[middle] == target) { return middle; } else { if (source[middle] > target) { right = middle - 1; } else { left = middle + 1; } } } return -1;}

public static int RBinSearch(int[] source, int target, int left, int right){ if (left > right) { return -1; } else { int middle = (int)(left + right) / 2; if (source[middle] == target) { return middle; } else { if (source[middle] > target) { return RBinSearch(source, target, left, right - 1); } else { return RBinSearch(source, target, left + 1, right); } } }}

####
{"ft_lang_label":"__label__zh","ft_lang_prob":0.7137172,"math_prob":0.9945531,"size":4891,"snap":"2020-10-2020-16","text_gpt3_token_len":2668,"char_repetition_ratio":0.18538982,"word_repetition_ratio":0.9935065,"special_character_ratio":0.30566347,"punctuation_ratio":0.15897436,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97790337,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,null,null,1,null,null,null,1,null,1,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-04-01T16:54:31Z\",\"WARC-Record-ID\":\"<urn:uuid:a59c336e-3c7d-4706-bc33-74629e736859>\",\"Content-Length\":\"15548\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:626738c5-6527-40e0-b531-430acae08ee9>\",\"WARC-Concurrent-To\":\"<urn:uuid:566210a4-e817-421b-b0d5-9d47a06bdd65>\",\"WARC-IP-Address\":\"104.201.28.170\",\"WARC-Target-URI\":\"https://www.consensusaudio.com/fzrl/r8jr.html\",\"WARC-Payload-Digest\":\"sha1:XZY5Y6XLR5AOB3KAZHWUPIM4NFZN2FCB\",\"WARC-Block-Digest\":\"sha1:NJHLHVHIQGU5WXLB4YTHFICUVFUMRNHK\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-16/CC-MAIN-2020-16_segments_1585370505826.39_warc_CC-MAIN-20200401161832-20200401191832-00480.warc.gz\"}"}