Update sentinalLinearSearch.js

Test case fix
This commit is contained in:
Rohith K 2019-11-04 13:51:00 +05:30 committed by GitHub
parent 408b0fc5df
commit 7e454924de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,14 +14,11 @@ export default function sentinalLinearSearch(array, seekElement, comparatorCallb
const lastEle = array[array.length - 1]; // Picking the last element in the array const lastEle = array[array.length - 1]; // Picking the last element in the array
const i = 0; const i = 0;
while (comparator.notEqual(i, array.length - 1)) while (comparator.notEqual(i, array.length - 1)) {
{ while(comparator.notEqual(array[i], seekElement)) {
while(comparator.notEqual(array[i], seekElement))
{
i = i + 1; i = i + 1;
} }
if(comparator.notEqual(i, array.length - 1)) if(comparator.notEqual(i, array.length - 1)) {
{
foundIndices.push(i); foundIndices.push(i);
i = i + 1; i = i + 1;
} }