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
9
votes
4 answers

Fast string search?

I have a vector of strings and have to check if each element in vector is present in a given list of 5000 words. Besides the mundane method of two nested loops, is there any faster way to do this in C++?
ofey
  • 423
  • 1
  • 7
  • 17
9
votes
1 answer

How to make cscope display full file paths during search

When I search for a C symbol or global definition using cscope, it displays the file-names and line numbers. I would like to see the full file-paths so that I can jump to my arch specific file. For example, when searching for global definition of…
manav m-n
  • 11,136
  • 23
  • 74
  • 97
9
votes
2 answers

Are there any algorithms to categorize an array among certain patterns?

For a simple problem of array length 5 to start with ( in practice the array length might be 20.. ) I have got a predefined set of patterns, like AAAAB, AAABA, BAABC, BCAAA, .... Each pattern is of the same length of the input array. I would need a…
colinfang
  • 20,909
  • 19
  • 90
  • 173
9
votes
1 answer

Modify Windows 7 Start menu search algorithm?

I really like the fuzzy matching search algorithm that Sublime Text 2 uses for its command palette and I was hoping to create something similar that runs through the Windows 7 Start menu search. I already found the Windows API Code Pack for .NET…
Joshua Sleeper
  • 107
  • 1
  • 7
9
votes
4 answers

How do I find line breaks and replace with
elements in JavaScript?

I am trying to find and replace line breaks in text using javascript. The following works. It replaces the character a with the character z. var text = "aasdfasdf"; text= text.replace(/a/g,"z"); alert(text); The following based on other posts on…
user1260310
  • 2,229
  • 9
  • 49
  • 67
9
votes
3 answers

Can you search Google Play using Intent?

Here's the situation: I want to open another app via implicit intent, but the user doesn't have adequate app. Can I open for him "Google Play Search Activity" with results including apps that contain components able to serve such intent (have…
hks
  • 757
  • 1
  • 6
  • 13
9
votes
4 answers

pipe search result to other tab/window/buffer in VIM

I found a nice feature of VIM search, i.e. listing all search results and the corresponding line numbers. For example: :g/for.*bar/# Question: Is there an "easy" way to pipe/put this into another window/tab/buffer? Cheers!
ezdazuzena
  • 6,120
  • 6
  • 41
  • 71
9
votes
3 answers

iOS: UIActivityIndicator in UISearchBar

Is it possible to display an UIActivityIndicator in the UISearchBar while searching?
filou
  • 1,609
  • 5
  • 26
  • 53
9
votes
2 answers

Postgresql: Full text search within lob possible?

We'd like to use PostgreSQL to store documents. As some of them might be up to 2 GB big, we have to use the lob-Datatype, where the large objects are stored in a separate table (pg_largeobject), referenced by an OID, as per the docs on large…
vera
  • 91
  • 1
  • 2
9
votes
6 answers

Fast filtering of a string collection by substring?

Do you know of a method for quickly filtering a list of strings to obtain the subset that contain a specified string? The obvious implementation is to just iterate through the list, checking each string for whether it contains the search string. Is…
mackenir
  • 10,801
  • 16
  • 68
  • 100
9
votes
3 answers

How is google search by image implemented?

I can just drag and drop any image in google and get results. :) How is it implimented ? What is the idea behind the algorithm ? Is that image data converted to anything for search or..... no idea ..
Sarath
  • 9,030
  • 11
  • 51
  • 84
9
votes
2 answers

Find the minimum gap between two numbers in an AVL tree

I have a data structures homework, that in addition to the regular AVL tree functions, I have to add a function that returns the minimum gap between any two numbers in the AVL tree (the nodes in the AVL actually represent numbers.) Lets say we have…
TheNotMe
  • 1,048
  • 2
  • 17
  • 33
9
votes
5 answers

How can I search my directory tree for contents within a file for a git managed project?

I like the unix find command but I always find it too 'fiddly' to use when I want to search through my project looking for a piece of text in any file in any directory or subdirectory. Is there an easier way to do this?
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
9
votes
5 answers

Rails ActiveRecord - Search on Multiple Attributes

I'm implementing a simple search function that should check for a string in either the username, last_name and first_name. I've seen this ActiveRecord method on an old RailsCast: http://railscasts.com/episodes/37-simple-search-form find(:all,…
gerky
  • 6,267
  • 11
  • 55
  • 82
9
votes
2 answers

Rails 3.1 Ransack HABTM

Is HABTM supported by Ransack? Having the models: Shop HABTM Categories Category HABTM Shops Can I use ransack to search a Shop by a single category? What does the form look like?