数列有序! Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 2 Accepted Submission(s) : 1 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给…
#include <stdio.h>#include <time.h> #define CLOCKS_PER_SEC ((clock_t)1000) int binsearch(int, int array[], int n); int main(){ int array[] = {2, 5, 6, 8, 9, 11, 12, 13, 14, 15, 16}; int tag = 9; int res = -1; clock_t start; clock_t finish; sta…
package com.gxf.search; /** * 测试折半查找or二分查找 * @author xiangfei * */ public class BiSearch { /** * 非递归实现,从第1个元素开始查找 * @param array * @param k * @return 0 查找失败 */ public int biSearch(int array[], int k){ int low = 1; int high = array.length - 1; while(l…