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

Search algorithm and its complexity

I was asked this question in an interview: Assume an infinite array of integers which is sorted. How would you search for an integer in this array? What would be time complexity? I guessed what the interviewer meant by infinite is that we dont know…
Brahadeesh
  • 2,245
  • 8
  • 40
  • 58
7
votes
5 answers

Use SQL to query javascript objects?

Is there a way to run an SQL query against javascript objects to find data within them? Specifically I'm looking for a way to query a few objects (each representing a table of data) and perform a join on them. I figured this was a long shot, but…
Jonathan Beebe
  • 5,241
  • 3
  • 36
  • 42
7
votes
0 answers

Maximal optimization for cosine similarity search

I have pre-made database full of 512 dimensional vectors and want to implement an efficient searching algorithm over them. Research Cosine similarity: The best algorithm in this case would consist of cosine similarity measure, which is basically a…
ShellRox
  • 2,532
  • 6
  • 42
  • 90
7
votes
1 answer

Exponential Search vs Binary Search

Does a binary search beat an exponential search in any way, except in space complexity?
Ram Kumar
  • 73
  • 1
  • 5
7
votes
1 answer

Output text in between two words

I would like to use PHP to input a certain text and the output should be the text in between two words. To clarify: Input: Lorem ipsum dolor sit amet Output: dolor sit
Deniz Zoeteman
  • 9,691
  • 26
  • 70
  • 97
7
votes
1 answer

How does searching with pip work?

Yes, I'm dead serious with this question. How does searching with pip work? The documentation of the keyword search refers to a "pip search reference" at https://pip.pypa.io/en/stable/user_guide/#searching-for-packages which is everything but a…
Regis May
  • 3,070
  • 2
  • 30
  • 51
7
votes
5 answers

What is the best auto-suggest search algorithm for javascript

Say I have an object: var names = ["john", "jane", "al", "mary", "zane" ... 1000+ Names] I want to create an auto-suggest to search these names. What's the most efficient way of doing this? I've read creating a trie or ternary data structure is…
doremi
  • 14,921
  • 30
  • 93
  • 148
7
votes
7 answers

Efficient way to implement a String Array "is in" method using Java

I have a requirement to present highly structured information picked from a highly un-structured web service. In order to display the info correctly, I have to do a lot of String matches and duplicate removals to ensure I'm picking the right…
IVR Avenger
  • 15,090
  • 13
  • 46
  • 57
7
votes
4 answers

Magento - Autocomplete Suggest Search Not Working

I have incorporated a new theme in Magento v1.4.2.0, and have completed all the necessary changes, but only following true Magento way of overriding the Magento modules & methods. My only problem is that the auto complete suggest search…
Knowledge Craving
  • 7,955
  • 13
  • 49
  • 92
7
votes
3 answers

Binary search of a C# list using delegate condition

I have a List that I want to search not for a given item but for an item satisfying a given condition. Given an item in the list I can test which of 4 conditions is true: the desired item must be to the left the desired item must be to the…
BCS
  • 75,627
  • 68
  • 187
  • 294
7
votes
1 answer

Bloom filters in a distributed environment

I have a system consisting of a few application instances, written in Java. Requests to them are load balanced for high availability. Every second, hundreds of small chunks of data (each consisting of a few simple strings) are received by this…
zgguy
  • 226
  • 1
  • 5
7
votes
2 answers

getting the total count of search results in wordpress

How to get the total count of results, in the search results page in wordpress ... i think my question is clear .i need the total number of search results that displayed in the search results page .And also need to find the count of results from…
Adarsh
  • 303
  • 1
  • 3
  • 13
7
votes
1 answer

Data structure for fast full text search

A trie seems like it would work for small strings, but not for large documents, so not sure (1-100's of pages of text). Maybe it is possible to combine an inverted index with a suffix tree to get the best of both worlds. Or perhaps using a b-tree…
Lance
  • 75,200
  • 93
  • 289
  • 503
7
votes
9 answers

How to check array data that matches from random characters in php?

I have an array like below: $fruits = array("apple","orange","papaya","grape") I have a variable like below: $content = "apple"; I need to filter some condition like: if this variable matches at least one of the array elements, do something. The…
Gagantous
  • 432
  • 6
  • 29
  • 69
7
votes
2 answers

Error with optimality in Iterative Deepening Depth First Search algorithm

I have implemented a version of Rush Hour (the puzzle board game) in Python as a demonstration of some AI algorithms. The game isn't important, because the AI is relatively independent of its details: I've attempted to implement a version of…
Sean
  • 3,002
  • 1
  • 26
  • 32