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

Find if vector contains pair with second element equal to X

I have this vector: using namespace std; vector< pair > vec = {}; And I want to find out if exists a pair with b == X. I know about std::find from but don't know how to apply it here. Should I write my own…
valentin
  • 2,596
  • 6
  • 28
  • 48
9
votes
3 answers

Is there a shorter key combination than :cn to go to the next item in the quickfix list?

I'm reading through a large C++ code base in Vim. Within a single file, I can do /foo n n n Now, if I want to search through more than one file, I have to do: :vimgrep /foo/ :cn :cn :cn Now, typing :cn is so much less convenient than n. Is there a…
anon
  • 41,035
  • 53
  • 197
  • 293
9
votes
6 answers

Match binary pattern including "don't cares"

I have a set of bit patterns, and want to find the index of the element in the set which matches a given input. The bit pattern contains "don't care" bits, that is x-es which matches both 0 and 1. Example The set of bit patterns are index abcd 0 …
Petter T
  • 3,387
  • 2
  • 19
  • 31
9
votes
7 answers

Search engine to integrate in a .NET stack

I am looking for a very robust software search engine to integrate in a .Net web site. The current proposed solution is Lucene.NET a stack based on Lucene. However, I would like to evaluate other search engines before making my mind up. The feature…
Sklivvz
  • 30,601
  • 24
  • 116
  • 172
9
votes
1 answer

Algorithm to search for a list of words in a text

I have a list of words, fairly small about 1000 or so. I want to check if any of the words in that list occur in an input text. If so I would like know which ones occur. The input text is a few hundred words each and these are text paragraphs from…
user220201
  • 4,514
  • 6
  • 49
  • 69
9
votes
3 answers

Writing an Inverted Index in C# for an information retrieval application

I am writing an in-house application that holds several pieces of text information as well as a number of pieces of data about these pieces of text. These pieces of data will be held within a database (SQL Server, although this could change) in…
Mike B
  • 12,768
  • 20
  • 83
  • 109
9
votes
10 answers

How do I create a stored procedure that will optionally search columns?

I'm working on an application for work that is going to query our employee database. The end users want the ability to search based on the standard name/department criteria, but they also want the flexibility to query for all people with the first…
Dillie-O
  • 29,277
  • 14
  • 101
  • 140
9
votes
2 answers

iOS how does NSMutableArray check if it contains NSNumber objects?

I'm writing some code that will be using NSMutableArray and storing int values within it, wrapped within NSNumbers. I would like to confirm that querying an iOS NSArray or NSMutableArray using new NSNumbers with same values is legal, of if I need…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
9
votes
1 answer

Rails Search Across Multiple Models

I have an issue. I have a show view that acts as a dashboard and brings in records from other models and then models associated to that. I have a simple search form that is working fine to search through one model, but I don't know how to have it…
looloobs
  • 761
  • 2
  • 11
  • 24
9
votes
2 answers

Is k-d tree efficient for kNN search. k nearest neighbors search

I have to implement k nearest neighbors search for 10 dimensional data in kd-tree. But problem is that my algorithm is very fast for k=1, but as much as 2000x slower for k>1 (k=2,5,10,20,100) Is this normal for kd trees, or am I doing something…
Andraz
  • 709
  • 2
  • 7
  • 16
9
votes
6 answers

Google Custom Search (CSEv2) help on styling?

I need help on styling the Google Custom Search Box (not the results) Old styles were using the form tags, where you could easily style the look & feel of the search box.
9
votes
1 answer

Implementing A* pathfinding in a 2D array

I'm in the process of making a 2D tile map and i'm now trying to implement A* pathfinding. I'm following the Wikipedia pseudocode for A*. Things are going quite well except for some weird behaviour in the decisions taken by the algorithm. My code so…
Mattias
  • 387
  • 1
  • 5
  • 17
9
votes
2 answers

Universal search field for jqgrid

I'm new to jqgrid and I found out that there are four ways to implement a search in jqgrid: a toolbar searching a custom searching a single field searching a more complex approach involving many fields and conditions - advanced searching I'd like…
hade
  • 1,715
  • 1
  • 16
  • 24
9
votes
2 answers

Get the text inside

element from an ajax jquery post response

Is there any way to get the text inside an element which is a response from an ajax jquery load. I need to get the text inside element which is present inside the response text from ajax page. Following is my ajax code: var url = '...'; …
ABHILASH SB
  • 2,122
  • 2
  • 21
  • 31

9
votes
4 answers

Binary search in an ordered list in java

Im looking for a way to implement a code in java that works the same way as a binary search in an ordered ArrayList but for an ordered List Thanks
JsMartinez
  • 321
  • 1
  • 5
  • 16