图  0.1
数据结构_第13章
ch8_1.cc File Reference

程序设计题第1题:以递归实现二分查找 More...

#include "Set.h"
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iostream>
#include <vector>
Include dependency graph for ch8_1.cc:

Go to the source code of this file.

Functions

template<class Key_T , class Other_T >
size_t binarySearch (Set::Set< Key_T, Other_T > data[], size_t low, size_t high, const Key_T &x)
 二分查找(递归版本) More...
 
int main (int argc, char const *argv[])
 测试程序 More...
 

Detailed Description

程序设计题第1题:以递归实现二分查找

Author
Guorui Wei (31301.nosp@m.7602.nosp@m.@qq.c.nosp@m.om)
Version
0.1
Date
2020-07-04

See the file LICENSE in the top directory of this distribution for more information.

Definition in file ch8_1.cc.

Function Documentation

◆ binarySearch()

template<class Key_T , class Other_T >
size_t binarySearch ( Set::Set< Key_T, Other_T >  data[],
size_t  low,
size_t  high,
const Key_T &  x 
)

二分查找(递归版本)

Template Parameters
Key_T键值的类型
Other_T其他值的类型
Parameters
data有序表
low查找范围下边界,即查[low, high]
high查找范围上边界,即查[low, high]
x目标键值
Returns
size_t 目标在表中的下标。high - low + 1表示查找失败

Definition at line 35 of file ch8_1.cc.

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char const *  argv[] 
)

测试程序

Parameters
argc参数个数
argv参数数组
Returns
int 返回值
Warning
要求.exe对其所在的目录有读写权限

部分测试结果将输出到一个文本文档中

Definition at line 58 of file ch8_1.cc.

References binarySearch().

Here is the call graph for this function: