mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-24 22:39:52 +03:00
... which is the entire point of sentinel search
This commit is contained in:
parent
654105c8ef
commit
ce3f01f54c
@ -41,11 +41,9 @@ int sentinel_linear_search( int arr[], int len, int key ){
|
|||||||
int temp = arr[len-1];
|
int temp = arr[len-1];
|
||||||
arr[len-1] = key;
|
arr[len-1] = key;
|
||||||
|
|
||||||
int i;
|
int i = 0;
|
||||||
for(i=0;arr[len-1]!=arr[i];i++){
|
while (arr[len-1] != arr[i]) {
|
||||||
if(i==len-1){
|
i++;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arr[len-1] = temp;
|
arr[len-1] = temp;
|
||||||
|
Loading…
Reference in New Issue
Block a user