Skip to content

Commit

Permalink
Update RecursiveLinearSearch.js
Browse files Browse the repository at this point in the history
  • Loading branch information
debnath003 authored Oct 3, 2023
1 parent a6dd54f commit c1961f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Recursive/RecursiveLinearSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
function recursiveLinearSearch (arr, key, index = 0) {
// Base case: If we have searched the entire array and haven't found the key, return -1.
if (index === arr.length) {
return -1;
return -1
}

// Base case: If the current element matches the key, return its index.
if (arr[index] === key) {
return index;
return index
}

// Recursive case: Continue searching in the rest of the array.
return recursiveLinearSearch(arr, key, index + 1);
return recursiveLinearSearch(arr, key, index + 1)
}

export { recursiveLinearSearch };
export { recursiveLinearSearch }

0 comments on commit c1961f1

Please sign in to comment.