折半查找的递归算法

折半查找的递归算法
int binary_search(int r[],int k,int low,int high)
{
	int mid;
	if(low<=high)
	{
			mid = (high+low)/2;
			if(r[mid]==k)
				retrun mid;
			else
			  if(r[mid]>k)
					return binary_search(r,k,low,mid-1);
				else
					return binary_search(r,k,mid+1,high);
	}
	else
		return 0;
}

    原文作者:查找算法
    原文地址: https://blog.csdn.net/The_star_is_at/article/details/73252113
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞