Previous topic | Next topic | Ada Home Page | Index

Search Algorithms

The best searching algorithm according to each of our criteria is as follows:

CriterionWhich is best?
Generalitylinear
Effectivenesseither
Terminationeither
Efficiencybinary
Elegancebinary

Computational complexity

To determine the efficiency of the algorithms, we need to consider their computational complexity ("big O notation"").

A search may or may not be successful. There is not necessarily any guarantee that the item being sought is present in the array.

In the tables below:

Linear search

best case 1
worst case N
average casePs(N/2) + Pu(N)
average caseN/2 (where Pu=0)

Since all cases but the best case have complexity proportional to N, we say that linear search is an "order N" algorithm.

O (N)

Binary search

best case 1
worst case log N
average case~log N
average case~log N (where Pu=0)

O (log N)


Previous topic | Next topic | Ada Home Page | Index
c-lokan@adfa.oz.au / 21 Feb 96