- Input an array A of an element an “data” to be sort
- LB=0,UB=n; mid = int((LB+UB)/2)
- Repeat Step 4 and 5 while(LB<=UB) and (A[Mid])!= data UB= mid-1
- If(data<A[mid])UB=mid-1ElseLB=mid+1
- Mid=int((LB+UB)/2)
- If(A[mid]==data)Printf(“The data is found”);ElsePrintf(“The data is not found”);
- Exit
No comments:
Post a Comment