Last active
November 12, 2020 00:06
-
-
Save the-mgi/b339aaed7c5c436507538e73097b2f30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LinearSearchRecursive(array: number[], key: number, index: number = 0): number { | |
if (index >= array.length) { | |
return -1; // in case if key is not present in the given array | |
} else if (array[index] === key) { | |
return index; | |
} | |
LinearSearchRecursive(array, key, index + 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment