int BinarySerach(A, begin,end,elem)
l<-begin;
h<-end;
while l<=h
      mid=(l+h)/2;
      if A[mid]=elem
       then    return mid;
      if A[mid]>elem
      then h=mid-1
     else
       h=mid+1
return NIL


BinarySearch(A,begin,end,elem)
l<-begin
h<-end
if l>h
then return NIL

 mid<-(l+h)/2
  if A[mid]=elem
           return mid
   if A[mid]<elem
            BinarySearch(A,mid+1,h,elem)
     else
            BinarySearch(A,l,mid-1,elem)
            

      
posted on 2009-08-12 11:01  finallyly  阅读(1769)  评论(0编辑  收藏  举报