Search algorithm

This is an old revision of this page, as edited by 69.140.141.215 (talk) at 01:51, 17 March 2004. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.


In codsd science, a search algorithm, broadly speaking, is an algorithm that takes a problem as input and returns a solution to the problem. Most of the algorithms studied by computer scientists that solve problems are kinds of search algorithms. The set of all possible solutions to a problem is called the search space. Brute-force search or "naive" search algorithms use the simplest, most intuitive method of searching through the search space, whereas search algorithms that use heuristics apply knowledge about the structure of the search space to try to reduce the amount of time spent searching.

List search algorithms are perhaps the most basic kind of search algorithm. The goal is to find one element of a set by some key (perhaps containing other information related to the key). As this is a common problem in computer science, the computational complexity of these algorithms has been well studied. The simplest such algorithm is linear search. It has O(n) running time, but can operate on a list containing the elements of the set. A more sophisticated list search algorithm is binary search. It runs in O(log(n)). This is significantly better than linear search for large lists of data, but it requires that the list be sorted before searching (see sort algorithm) and also be random access. Interpolation search is better than binary search for large sorted lists. However, the underlying data structure must allow such kind of searching. Hash tables are also used for search; they are the method of choice in most circumstances today. Grover's algorithm is a quantum algorithm that offers quadratic speedup over the classical linear search for unsorted lists.

Tree search algorithms search nodes of trees. Examples include Depth-first search, Breadth-first search, Best-first search, and A*.

Many of the problems in graph theory are solved using search algorithms, such as Dijkstra's algorithm, Kruskal's algorithm, the nearest neighbour algorithm, and Prim's algorithm.

Game-playing computer programs and other forms of artificial intelligence like machine planning and often use search algorithms like the Minimax algorithm, search tree pruning, and alpha-beta pruning.

String searching algorithms search for patterns within strings.

Genetic algorithms use ideas from evolution as heuristics for reducing the search space.

Simulated annealing is a probabilistic search algorithm.