| Title |
binary.cpp |
| URL |
http://www.cprogramming.com/source/binary.cpp |
| Category |
10 |
| Description |
binary search that returns a negative one if the number is not found This code does a bubble sort and then proforms the binary search |
| Contact |
David Thompson
|
| Added |
08-10-2002 at 01:30 p.m. |
| Last Updated |
08-10-2002 at 01:32 p.m. |
|
|
|
| Current Rating |
4.65217391304348 |
| Rate Resource |
|
|
| Number of Reviews |
1 |
|
Review this Resource
|
| Reviews: |
- It is an ok source, it could have been written better. The code needs to be changed in the do loop so there are not any more errors or crashes. (ex:
do
{
if(b > a[mid])
{
low = mid + 1;
mid = (high + low) / 2;
}
else if(b < a[mid])
{
high = mid - 1;
mid = (high + low) / 2;
}
else if(b == a[mid])
{
return mid + 1;
}
}while(low < high);
But otherwise is good.
posted at 06:25 p.m. on 02-13-2006
|
|