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
8
votes
1 answer

5 numbers such that their sum equals 0

Given 5 arrays of size n: a, b, c, d, e. How many (i, j, k, g, h) are there such that a(i) + b(j) + c(k) + d(g) + e(h) = 0 ? Can this problem be solved with complexity better than O(n^2 + n^3) (using hash map) ?
Xeing
  • 314
  • 3
  • 10
8
votes
4 answers

PHP preg_match_all search and replace

I have tried about a million different regexes and I just can't wrap my head around this one (admittedly a lot of regex is out of my grasp). In my text I have variables like this: {{$one}} {{$three.four.five}} {{$six.seven}} And I have an array…
Alex Howe
  • 103
  • 1
  • 1
  • 8
8
votes
6 answers

PHP Search Array column for match

I have an array as below, which has multiple columns. I want to search in the first column for a specific value, and have the rows that match returned. Is that possible to do? For example: Array ( [0] => Array ( [id] => 1 [column2] => value2…
David
  • 316
  • 1
  • 2
  • 10
8
votes
3 answers

Grep after and before lines of last Match

I am searching through few logs and I want to grep the last match along with it's above and below few lines. grep -A10 -B10 "searchString" my.log will print all the matches with after and before 10 lines grep "searchString" my.log | tail -n 1 will…
RaceBase
  • 18,428
  • 47
  • 141
  • 202
8
votes
3 answers

Reverse Search Best Practices?

I'm making an app that has a need for reverse searches. By this, I mean that users of the app will enter search parameters and save them; then, when any new objects get entered onto the system, if they match the existing search parameters that a…
edub
  • 893
  • 2
  • 9
  • 11
8
votes
4 answers

How can we protect ourselves from other third parties installing DLLs with the same names as some of ours into C:\WINDOWS?

Our product includes several DLLs built from open source into files with default names as delivered by the open source developers. We're careful to install the files in our own directories and we carefully manage the search path (only for our…
Integer Poet
  • 747
  • 5
  • 19
8
votes
2 answers

Add results into WordPress search results

I would like to add/inject/append extra results into the WordPress search results. At the moment WordPress only allows you to "adjust" the query that is being executed on its own database, but doesn't allow you to modify (or in WordPress lingo,…
Ruben
  • 1,427
  • 3
  • 17
  • 25
8
votes
1 answer

How can I support wildcards in user-defined search strings in Python?

Is there a simple way to support wildcards ("*") when searching strings - without using RegEx? Users are supposed to enter search terms using wildcards, but should not have to deal with the complexity of RegEx: "foo*" => …
AnC
8
votes
1 answer

How to display Alpha Beta Pruning algorithm result?

Updates Update 1 I tried this (2nd line): I added changing node color as first instruction in alphabeta function. I am getting this result: Green nodes are visited nodes. It looks like, algorithm is going throw nodes correctly, right? But how to…
8
votes
2 answers

Is fibonacci search faster than binary search?

I read some materials that claims Fibonacci search is faster than binary search on average,and the main cause is "it involves only addition and subtraction,not division by 2". I have some questions: 1.Is Fibonacci search faster than binary search…
Mobility
  • 3,117
  • 18
  • 31
8
votes
2 answers

Finding text using ReSharper

Resharper is a great tool, the only thing I seem to be missing is an easy text search option. Searching online I have come across a few options (pattern search,key word search) , none of my found options were simple/quick searches. I am looking…
Mike
  • 1,122
  • 2
  • 13
  • 25
8
votes
4 answers

Storing search result for paging and sorting

I've been implementing MS Search Server 2010 and so far its really good. Im doing the search queries via their web service, but due to the inconsistent results, im thinking about caching the result instead. The site is a small intranet (500…
Mattias
  • 684
  • 3
  • 7
  • 16
8
votes
2 answers

search similar meaning phrases with nltk

I have a bunch of unrelated paragraphs, and I need to traverse them to find similar occurrences such as that, given a search where I look for object falls, I find a boolean True for text containing: Box fell from shelf Bulb shattered on the…
dmvianna
  • 15,088
  • 18
  • 77
  • 106
8
votes
2 answers

what is the better way to search in millions of file names with wildcard(GLOB) support

i am working on a small search engine to display a matching file names with full path. and important thing is that i need to provide wildcard(GLOB) search like *.doc or *list*.xlx or *timesheet* or ???.doc or something like that. i found some…
Mahes
  • 3,938
  • 1
  • 34
  • 39
8
votes
3 answers

In Android how to change the color of a particular letter/character which is being searched inside the List

I have a ListView containing certain items and I have placed a EditText above the list to provide the Search facility to the user, means, by typing inside the EditText and clicking any button etc., user can search whether certain item is present in…
swdeveloper
  • 908
  • 1
  • 11
  • 33