Lably
Skip to content

Search algorithm

Any algorithm which solves the search problem

  • 5 min read
  • 2 chapters

Related on Lably

Through Computer science, Algorithm and Data structure

Although search engines use search algorithms, they belong to the study of information retrieval, not algorithmics.

The appropriate search algorithm to use often depends on the data structure being searched, and may also include prior knowledge about the data. Search algorithms can be made faster or more efficient by specially constructed database structures, such as search trees, hash maps, and database indexes.

Search algorithms can be classified based on their mechanism of searching into three types of algorithms: linear, binary, and hashing. Linear search algorithms check every record for the one associated with a target key in a linear fashion. Binary, or half-interval, searches repeatedly target the center of the search structure and divide the search space in half. Comparison search algorithms improve on linear searching by successively eliminating records based on comparisons of the keys until the target record is found, and can be applied on data structures with a defined order. Digital search algorithms work based on the properties of digits in data structures by using numerical keys. Finally, hashing directly maps keys to records based on a hash function.

Algorithms are often evaluated by their computational complexity, or maximum theoretical run time. Binary search functions, for example, have a maximum complexity of O(log n), or logarithmic time. In simple terms, the maximum number of operations needed to find the search target is a logarithmic function of the size of the search space.

Applications of search algorithms

Specific applications of search algorithms include:

  • Problems in combinatorial optimization, such as:
    • The vehicle routing problem, a form of shortest path problem
    • The knapsack problem: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible.
    • The nurse scheduling problem
  • Problems in constraint satisfaction, such as:
  • In game theory and especially combinatorial game theory, choosing the best move to make next (such as with the minmax algorithm)
  • Finding a combination or password from the whole set of possibilities
  • Factoring an integer (an important problem in cryptography)
  • Search engine optimization (SEO) and content optimization for web crawlers
  • Optimizing an industrial process, such as a chemical reaction, by changing the parameters of the process (like temperature, pressure, and pH)
  • Retrieving a record from a database
  • Finding the maximum or minimum value in a list or array
  • Checking to see if a given value is present in a set of values

Sign in to keep reading

One more chapter is free with a Lably account.

More in Theoretical computer science