Questions tagged [search]

Questions about search algorithm mechanics and implementation. *NOT* for questions about using search tools within an API (e.g. Google, Bing, Facebook).

Searching is one of the most common and important tasks in Computer Science.

The most basic search algorithm is a (also called "sequential search"). Each item in a collection of data is examined in sequence until the sought item is found.

If the collection in question has already been sorted, for instance, then a more efficient is possible.

Search can become more complex when, rather than finding one instance of a specific item, we want to find all items meeting a certain set of criteria. For instance a query can specify extremely complex search criteria, and much of relational database design involves the planning of an efficient way to perform those searches.

Another more complex search scenario is graph search, in which a series of nodes and edges must be traversed. Common algorithms for this domain include and . In many cases, a heuristic search algorithm such as can achieve more efficient results by making use of additional information about the problem.


Do not use this tag for questions about specific search tools within an API. Some more relevant tags for that would be the following:

37207 questions
7
votes
1 answer

Google Maps API 3 search box

I cannot figure out how to implement the search box in my google maps. I have it where the user can pick some stuff from a form and it loads the markers on the map. Now I want to add where they can type in the city and state using the google search…
shinjuo
  • 20,498
  • 23
  • 73
  • 104
7
votes
1 answer

Mercurial repo search

Is there a command that searches a specified string over a Mercurial repository and displays revisions where it is found? If not, are there any examples of how to implement it?
utapyngo
  • 6,946
  • 3
  • 44
  • 65
7
votes
8 answers

PHP mysql search queries

I'm trying to create a search engine for an inventory based site. The issue is that I have information inside bbtags (like in [b]test[/b] sentence, the test should be valued at 3, whereas sentence should be valued at 1). Here is an example of an…
Jess
  • 8,628
  • 6
  • 49
  • 67
7
votes
4 answers

Is there a name for this type of binary search?

In writing some code today, I have happened upon a circumstance that has caused me to write a binary search of a kind I have never seen before. Does this binary search have a name, and is it really a "binary" search? Motivation First of all, in…
Cory Klein
  • 51,188
  • 43
  • 183
  • 243
7
votes
3 answers

How to find the smallest and biggest number in an array?

Hello how can I find the smallest and biggest number in delphi? Suppose I have 10 different numbers stored in an array: How can I find the biggest number and smallest numbers in my array?
dnaz
  • 276
  • 5
  • 14
7
votes
5 answers

Search for nearest value in an array of doubles in C++?

I have a sorted array of double values in C++. Is there an STL function that will return the index of the nearest value in the array to a given double value? For example, given the following array double myarray[5] = { 1.0, 1.2, 1.4. 1.5, 1.9…
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
7
votes
3 answers

SwiftUI - Perform action when cancel is clicked - .searchable function

When using the .searchable(text: $text) function, a cancel button appears in the search bar when searching. Is there any way to perform an action when the cancel button is clicked? I would like to call a function when cancel is clicked, but cannot…
nickreps
  • 903
  • 8
  • 20
7
votes
1 answer

MySQL case insensitive search on varbinary field?

I have a varbinary field id like to do a case-insensitive search on. I know that the way varbinary fields work prohibits you from doing something like so: WHERE LOWER(page_title) = LOWER("Gasket") So is there a way to do this? I imagine I could…
Adam Meyer
  • 1,505
  • 1
  • 19
  • 28
7
votes
1 answer

Google like autosuggest / typeahead (suggesting keywords / phrases) with Solr

Requirements I need a google like suggestions in a search box. Solr is already a given. The results should look like this: searchterm Alex results Alexander Behling, Alexander Someone ... searchterm cab results cable, high voltage cable, cable…
Marc Johnen
  • 379
  • 3
  • 11
7
votes
3 answers

High level explanation of Similarity Class for Lucene?

Do you know where I can find a high level explanation of Lucene Similarity Class algorithm. I will like to understand it without having to decipher all the math and terms involved with searching and indexing.
Geo
  • 8,663
  • 13
  • 63
  • 93
7
votes
3 answers

PHP, in_array and fast searches (by the end) in arrays

I have a doubt about what's the better way to make a fast search in arrays (I'm talking about an specific case). Supose that I have an array L = [A, B, C] (when I start). While the program is running, may be L will grow (but by the end), one…
castarco
  • 1,368
  • 2
  • 17
  • 33
7
votes
4 answers

Effective ways of finding an element in a Javascript array

I am using an array with titles. Each titles index corresponds to an id in a database which contains html for that given title. Lets say I have a string which contains one of the titles. title = "why-birds-fly"; titles[] // an array which contains…
Willem
  • 1,094
  • 1
  • 12
  • 23
7
votes
1 answer

Atom: Can't search for Packages or Themes in the Install Packages section of Settings

I'm new to Atom (and relatively new to programming) and I just installed it about a few hours ago. I was trying to set it up by installing some new packages and themes in the Install Packages section of Settings. It was working fine for a while but…
terbik
  • 73
  • 1
  • 4
7
votes
2 answers

O(1) lookup for ranges

Does there exist a way to look up a value's corresponding range quickly? For example: I have a bunch of pre-specified ranges: [0,50), [50, 100), [100,200), etc. I want to check which pre-specified range a decimal value falls under: I know that if…
CosmoVibe
  • 223
  • 1
  • 7
7
votes
5 answers

Best way to search for a saturation value in a sorted list

A question from Math Battle. This particular question was also asked to me in one of my job interviews. " A monkey has two coconuts. It is fooling around by throwing coconut down from the balconies of M-storey building. The monkey wants to know the…
abhilash
  • 5,605
  • 3
  • 36
  • 59