Example
int search(int a[],int &n, int x)
{ //a[] is an array of n elements
for (int i=0; i<n; i++)
if (a[i] == x) return i;
return -1;
}
Run-time behaviour:
Best case
average case
worst case
Next slide
Back to first slide
View graphic version