Skip to content

Instantly share code, notes, and snippets.

@AlexJuca
Created December 27, 2015 14:39
Show Gist options
  • Save AlexJuca/322d1d95ee7c5b677c8a to your computer and use it in GitHub Desktop.
Save AlexJuca/322d1d95ee7c5b677c8a to your computer and use it in GitHub Desktop.
timedLinearSearch
public static void findStudent(int key, int[] studentList) {
final long startTime = System.nanoTime();
int N = studentList.length;
for(int i = 0; i < N; i++) {
if(studentList[i] == key) {
System.out.println("Key has been found");
} else System.out.println(" Key was not found ");
}
final long endTime = System.nanoTime();
System.out.println("Total execution time: " + (endTime - startTime) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment