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
10
votes
2 answers

Finding an Image Inside Another Image

I'm trying to build an application that solves a puzzle (trying to develop a graph algorithm), and I don't want to enter sample input by hand all the time. Edit: I'm not trying to build a game. I'm trying to build an agent which plays the game…
marvin
  • 1,847
  • 4
  • 15
  • 20
10
votes
6 answers

Change the magnifying glass icon on a UISearchBar

I want to be able to set my own image for the little magnifying glass icon on a UISearchBar. I'd also like to be able to move it around if possible. Any ideas? Currently, I only need support for iOS5 and above.
user319436
10
votes
5 answers

Find maximum value in an array by recursion

// Find a maximum element in the array. findMax(A) findMaxHelper(A, 0, A.length) findMaxHelper(A, left, right) if (left == right - 1) return A[left] else max1 = findMaxHelper(A, left, (right + left) / 2) max2 =…
Justin Bains
  • 109
  • 1
  • 1
  • 8
10
votes
2 answers

eshell search history

I'm using emacs eshell and would like to search back through my command history. In bash you would do C-r then type something and then press C-r repeatedly until you find the command you want. On eshell it seems I have to type M-r and then type…
shmish111
  • 3,697
  • 5
  • 30
  • 52
10
votes
2 answers

C++ searching text file for a particular string and returning the line number where that string is on

Is there a particular function in c++ that can return the line number of a particular string i want to find? ifstream fileInput; int offset; string line; char* search = "a"; // test variable to search in file // open file to…
John Marston
  • 11,549
  • 7
  • 23
  • 18
10
votes
4 answers

Use command grep and locate

How I can make the grep command locate certain words in the files specified by the routes found by the locate command? locate my.cnf | grep user (I want that grep command search the word "user" on the files found for locate command)
Jhonathan
  • 1,611
  • 2
  • 13
  • 24
10
votes
0 answers

Can I combine fuzzy and proximity searches in Apache Lucene's standard syntax?

I am searching a codebase indexed by OpenGrok, the -a option has been enabled to allow the first character of a search term to be a wildcard. I would like to find all occurrences of method foo that take some string parameter (foo("") with one or…
MilesHampson
  • 2,069
  • 24
  • 43
10
votes
3 answers

Make Eclipse's Incremental Find wrap around the end of the page

In Eclipse you can hit Ctrl + J to use Incremental Find which is awesome. But if you start out half way down the page, and try to find something in the top half it won't find it because it doesn't wrap around, it stops at the bottom of the page. So…
jb.
  • 9,921
  • 12
  • 54
  • 90
10
votes
2 answers

How To Search Instagram via API Query?

I would like to build a small 'instant image search' app powered by Instagram photos. This would be like Google Instant where you start typing and results are displayed/updated as you type more letters. You can see a live demo app powered by Google…
Jake
  • 1,285
  • 11
  • 40
  • 119
10
votes
1 answer

Chrome Developer Tools: non-case-sensitive search

Can Developer Tools in Chrome perform a non-case-sensitive search?
Kozuch
  • 2,272
  • 3
  • 26
  • 38
10
votes
2 answers

How to escape search patterns or regular expressions in vimscript?

I am writing a vim plugin in vimscript where I need to search another file for the word currently under the cursor using following command: exec 'vimgrep /' . expand('') . '/g filename' I need to ensure that there are no regular expressions…
user1392329
10
votes
1 answer

Is this the right way to use Sphinx from PHP?

I am just starting with Sphinx. So far I got it installed successfully, got a table called profiles on my MySQL database indexed and am able to get the correct results back using the PHP API. I am using CodeIgniter so I wrapped the default PHP API…
user967451
10
votes
6 answers

Emacs: Combine iseach-forward and recenter-top-bottom

Thank you very much in advance for helping. In Emacs, I like to use iseach-forward (C-s) but I'd like it ever more if the highlighted fount words would be centered in the middle of the screen instead of at the very bottom. I find myself doing this…
RafaelGP
  • 1,749
  • 6
  • 20
  • 35
10
votes
5 answers

Django Haystack - Show results without needing a search query?

I would like to display all results which match selected facets even though a search query has not been inserted. Similar to how some shop applications work e.g. Amazon e.g. Show all products which are "blue" and between $10-$100. Haystack does not…
RadiantHex
  • 24,907
  • 47
  • 148
  • 244
10
votes
34 answers

Array Searching code challenge

Here's my (code golf) challenge: Take two arrays of bytes and determine if the second array is a substring of the first. If it is, output the index at which the contents of the second array appear in the first. If you do not find the second array in…
RCIX
  • 38,647
  • 50
  • 150
  • 207