Linear Search
Description
This applet demonstrates the linear search algorithm using a simple array.
The algorithm takes O(n) time in the worst case.
 Create: Type a value between 3 and 19 in the text field, and click the "Create" button to construct an array of that size. The
array is populated with randomly generated numbers.
 Search: Type a value to be searched in the text field, and click the "Search" button.
Code
(Linear search on a simple array)
boolean linearSearch(int key){
for(int i=0; i < size; i++){
if(key == arr[i]) return true;
}
return false;
}

Data Structures and Algorithms
Java Applets Centre
R. Mukundan
Department of Computer Science
University of Canterbury
Private Bag 4800, Christchurch
New Zealand.