程序填空题:折半查找算法
本题要求实现折半查找的递归查找操作。 例如对于下图的有序表:

### 输入样例:
```
2
21 70
```
### 输出样例:
```out
21 is found
70 is not found
```
###程序如下:
```c++
#include
#include
typedef int KeyType;
typedef struct {
KeyType *data; /*表基址*/
int length; /*表长*/
}SSTable;
void CreatSSTable(SSTable *ST);/*有序表创建,由裁判实现,细节不表*/
int BiSearch(SSTable ST,KeyType e,int low,int high);
int main()
{
SSTable ST;
int n,result,i;
KeyType e;
CreatSSTable(&ST);
scanf("%d",&n);
for( i=0;i {
scanf("%d",&e);
result = BiSearch(ST,e,1,ST.length);
if(result) printf("%d is found\n",e);
else printf("%d is not found\n",e);
}
return 0;
}
int BiSearch(SSTable ST,KeyType e,int low,int high)
{
int mid;
if(@@[low>high](2)) return 0;
mid=(low+high)/2;
if(ST.data[mid]==e) return mid;
if(e else @@[ return BiSearch(ST,e, mid+1,high) ](2);
}
```
答案:
第1空:low>high
第2空: BiSearch(ST,e, low,mid-1)
第3空: return BiSearch(ST,e, mid+1,high)

### 输入样例:
```
2
21 70
```
### 输出样例:
```out
21 is found
70 is not found
```
###程序如下:
```c++
#include
#include
typedef int KeyType;
typedef struct {
KeyType *data; /*表基址*/
int length; /*表长*/
}SSTable;
void CreatSSTable(SSTable *ST);/*有序表创建,由裁判实现,细节不表*/
int BiSearch(SSTable ST,KeyType e,int low,int high);
int main()
{
SSTable ST;
int n,result,i;
KeyType e;
CreatSSTable(&ST);
scanf("%d",&n);
for( i=0;i
scanf("%d",&e);
result = BiSearch(ST,e,1,ST.length);
if(result) printf("%d is found\n",e);
else printf("%d is not found\n",e);
}
return 0;
}
int BiSearch(SSTable ST,KeyType e,int low,int high)
{
int mid;
if(@@[low>high](2)) return 0;
mid=(low+high)/2;
if(ST.data[mid]==e) return mid;
if(e
}
```
答案:
第1空:low>high
第2空: BiSearch(ST,e, low,mid-1)
第3空: return BiSearch(ST,e, mid+1,high)