Java Applets Centre
Linear Search

This applet demonstrates the linear search algorithm using a simple array. The algorithm takes O(n) time in the worst case.

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.