# Search algorithm

﻿
Search algorithm

In computer science, a search algorithm, broadly speaking, is an algorithm that takes a problem as input and returns a solution to the problem, usually after evaluating a number of possible solutions. 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 "naïve"/uninformed search algorithms use the simplest method of searching through the search space, whereas informed search algorithms use heuristic functions to apply knowledge about the structure of the search space to try to reduce the amount of time spent searching.

Uninformed search

An uninformed search algorithm is one that does not take into account the specific nature of the problem. As such, they can be implemented in general, and then the same implementation can be used in a wide range of problems thanks to abstraction. The drawback is that most search spaces are extremely large, and an uninformed search (especially of a tree) will take a reasonable amount of time only for small examples. As such, to speed up the process, sometimes only an informed search will do.

List search

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, which simply examines each element of the list in order. It has expensive O(n) running time, where "n" is the number of items in the list, but can be used directly on any unprocessed list. A more sophisticated list search algorithm is binary search; it runs in O(log "n") time. This is significantly better than linear search for large lists of data, but it requires that the list be sorted before searching (see sorting algorithm) and also be random access. Interpolation search is better than binary search for large sorted lists with fairly even distributions, but has a worst-case running time of O("n").

Grover's algorithm is a quantum algorithm that offers quadratic speedup over the classical linear search for unsorted lists. However, it requires a currently non-existent quantum computer on which to run.

Hash tables are also used for list search, requiring only constant time for search in the average case, but more space overhead and terrible O("n") worst-case search time. Another search based on specialized data structures uses self-balancing binary search trees and requires O(log "n") time to search; these can be seen as extending the main ideas of binary search to allow fast insertion and removal. See associative array for more discussion of list search data structures.

Most list search algorithms, such as linear search, binary search, and self-balancing binary search trees, can be extended with little additional cost to find all values less than or greater than a given key, an operation called "range search". The glaring exception is hash tables, which cannot perform such a search efficiently.

Tree search

Tree search algorithms are the heart of searching techniques for structured data. These search trees of nodes, whether that tree is explicit or implicit (generated on the go). The basic principle is that a node is taken from a data structure, its successors examined and added to the data structure. By manipulating the data structure, the tree is explored in different orders - for instance, level by level (breadth-first search) or reaching a leaf node first and backtracking (depth-first search). Other examples of tree-searches include iterative-deepening search, depth-limited search, bidirectional search, and uniform-cost search.

It should be realized that the efficiency of a tree search (compared to other search methods) is highly dependent upon the number and structure of nodes in relation to the number of items on that node. If there are a large number of items on one or more nodes, there may well be a requirement to utilize a specific different search technique for locating items within that particular set. In other words, a tree search is not mutually exclusive with any other search technique that may be used for specific sets. It is simply a method of reducing the number of relevant items to be searched (by whatever method) to those within certain branches of the tree. For example, the Greater London telephone directory may still contain entries for 20,000+ people whose surname is 'SMITH' belonging on a tree branch 'surnames beginning S'. The list of names may, or may not be, further subdivided by subscribers initials. A binary search may be appropriate to locate a particular person with forename 'Alias' and perhaps thereafter a linear search to locate a particular address.

Graph search

Many of the problems in graph theory can be solved using graph traversal algorithms, such as Dijkstra's algorithm, Kruskal's algorithm, the nearest neighbour algorithm, and Prim's algorithm. These can be seen as extensions of the tree-search algorithms.

Informed search

In an informed search, a heuristic that is specific to the problem is used as a guide. A good heuristic will make an informed search dramatically out-perform any uninformed search.

There are few prominent informed list-search algorithms. A possible member of that category is a hash table with a hashing function that is a heuristic based on the problem at hand. Most informed search algorithms explore trees Fact|date=August 2008. These include best-first search, and A*. Like the uninformed algorithms, they can be extended to work for graphs as well.

Adversarial search

In games such as chess, there is a game tree of all possible moves by both players and the resulting board configurations, and we can search this tree to find an effective playing strategy. This type of problem has the unique characteristic that we must account for any possible move our opponent might make. To account for this, game-playing computer programs, as well as other forms of artificial intelligence like machine planning, often use search algorithms like the minimax algorithm, search tree pruning, and alpha-beta pruning.

Constraint satisfaction

This is a type of search which solves constraint satisfaction problems where, rather than looking for a path, the solution is simply a set of values assigned to a set of variables. Because the variables can be processed in any order, the usual tree search algorithms are too inefficient. Methods of solving constraint problems include combinatorial search and backtracking, both of which take advantage of the freedom associated with constraint problems. Common tricks or techniques involved in backtracking is Constraint propagation, which is a general form of Forward checking. Other local search algorithms, such as generic algorithm, which minimize the conflicts, also do a good job.

Other types

* String searching algorithms search for patterns within strings; one popular data structure that makes this more efficient is the suffix tree
* Genetic algorithms and Genetic programming use ideas from evolution as heuristics for reducing the search space
* Sorting algorithms necessary for executing certain search algorithms
* Simulated annealing is a probabilistic search algorithm
* Recommender systems also use statistical methods to rank results in very large data sets
* Tabu search is a technique to avoid discrete searches getting stuck in local minima
* Federated search
* Minimax which can be highly optimized using alpha-beta pruning is an algorithm to search for good moves in zero-sum games
* Ternary search

ee also

* Selection algorithm
* No free lunch in search and optimization
* Secretary problem is an online (ie sequentially presented) search problem with imperfect information, and a statistically optimal strategy.

External links

* [http://www.gp-field-guide.org.uk/ A Field Guide to Genetic Programming] by Poli, Langdon, and McPhee. Available as a free PDF, or in printed form from Lulu.com.
* [http://en.wikiversity.org/wiki/Uninformed_Search_Project Self-Guided Lesson on Uninformed Search] Go to the Wikiversity and teach yourself to program an uninformed search solution.

Wikimedia Foundation. 2010.

### Look at other dictionaries:

• search algorithm — paieškos algoritmas statusas T sritis automatika atitikmenys: angl. search algorithm vok. Suchalgorithmus, m rus. алгоритм поиска, m pranc. algorithme de recherche, m …   Automatikos terminų žodynas

• A* search algorithm — In computer science, A* (pronounced A star ) is a best first, graph search algorithm that finds the least cost path from a given initial node to one goal node (out of one or more possible goals). It uses a distance plus cost heuristic function… …   Wikipedia

• Rabin-Karp string search algorithm — The Rabin Karp algorithm is a string searching algorithm created by Michael O. Rabin and Richard M. Karp in 1987 that uses hashing to find a substring in a text. It is used for multiple pattern matching rather than single pattern matching. For… …   Wikipedia

• Boyer–Moore string search algorithm — The Boyer–Moore string search algorithm is a particularly efficient string searching algorithm, and it has been the standard benchmark for the practical string search literature. [Hume and Sunday (1991) [Fast String Searching] SOFTWARE PRACTICE… …   Wikipedia

• Binary search algorithm — for performing binary searches on Java arrays and Lists, respectively. They must be arrays of primitives, or the arrays or Lists must be of a type that implements the Comparable interface, or you must specify a custom Comparator object. Microsoft …   Wikipedia

• B* search algorithm — In computer science, B* (pronounced B star ) is a best first, graph search algorithm that finds the least cost path from a given initial node to one goal node (out of one or more possible goals). First published by Hans Berliner in 1979, it is… …   Wikipedia

• D* search algorithm — In computer science and robotics, the D* algorithm (pronounced D star ) is a dynamic version of the backward variant of Dijkstra s algorithm and A* search algorithm. Also known as Stentz s Algorithm, it was first developed by Anthony Stentz in… …   Wikipedia

• Deducting Search Algorithm — The Deducting Search Algorithm (DSA), also known as the Holmes Engine after the author Sir Arthur Conan Doyle’s famous sleuth, is a mathematical formula that interprets the choices made by the seeker whilst looking for a particular piece of… …   Wikipedia

• algorithm — UK US /ˈælgərɪðəm/ noun [C] IT ► a set of mathematical instructions that must be followed in a fixed order, and that, especially if given to a computer, will help to calculate an answer to a mathematical problem: a computer/mathematical/search… …   Financial and business terms

• Search optimization — may refer to:*Search algorithm *Search engine *Search engine optimization …   Wikipedia

### Share the article and excerpts

##### Direct link
Do a right-click on the link above
and select “Copy Link”

We are using cookies for the best presentation of our site. Continuing to use this site, you agree with this.