Created
January 14, 2021 18:25
-
-
Save iamrajendra/13b0f9f12a033b9ec87f7460bde35748 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
private static int linearSearch() { | |
int arr[] = new int[]{10, 20, 80, 30, 60, 50, 110, 100, 130, 170}; | |
int x = 110; | |
for (int i = 0; i < arr.length; i++) { | |
if (x == arr[i]) return i; | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment