A: 8 3 6 2 6
  1. Key=6, Start=0, n=5. Search the list from the beginning, returning the index of the first occurence of element 6.
  2. Key=6, Start=3, n=2. Start at A[3] and search the list, returning a pointer to the first occurence of element 6.
  3. Key=9, Start=0, n=5. Start at the first element and search the list for the number 9. Since it is not found, return the value -1.

The sequential search algorith applies to any array for which the operator "==" is defined for the item type. A fully general search algorith requires templates and operator overloading. The following functions implements the sequential search for an integer array.

Sequential Search Function.

int SeqSearch(int list[ ], int start, int n, int key)
{
	for(int i=start;i< n; i++)
		if (list[i]==key)
			return i;
}
return -1;
}