mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 13:31:21 +03:00
Merge pull request #103 from koseokkyu/otherbinarysearch
correct compilation error and logic error at Otherbinarysearch in search folder
This commit is contained in:
commit
694bc20327
@ -2,15 +2,15 @@
|
||||
#include <stdlib.h>
|
||||
#define len 5
|
||||
|
||||
int binarySearch(int array[] , int len , int searchX)
|
||||
{
|
||||
|
||||
int binarySearch(int array[], int leng, int searchX)
|
||||
{
|
||||
int pos = -1, right, left, i = 0;
|
||||
|
||||
left = 0;
|
||||
right = len - 1;
|
||||
right = leng - 1;
|
||||
|
||||
for(i = 0; i < len ; i++)
|
||||
for (i = 0; i < leng; i++)
|
||||
{
|
||||
pos = (left + right) / 2;
|
||||
|
||||
@ -19,10 +19,10 @@ int binarySearch(int array[] , int len , int searchX)
|
||||
else
|
||||
{
|
||||
if (array[pos] < searchX)
|
||||
right = pos - 1;
|
||||
left = pos + 1;
|
||||
else
|
||||
{
|
||||
left = pos + 1 ;
|
||||
right = pos - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user