Questions tagged [search]
This tag is for questions about search algorithms, tools, and technologies.
44 questions
11
votes
1
answer
4k
views
Z-Algorithm for pattern matching in strings
I was trying to refactor the following Python code (keeping the same time-complexity) which is an implementation of Z-Algorithm for pattern matching in strings.
...
12
votes
2
answers
615
views
Finding a word within a pre-defined set using a search string with wildcards
The other day I was intrigued by this question (originally from here):
Write a program that answers YES/NO search queries containing * placeholders. Example: if the data you have is (hazem, ahmed,...
5
votes
2
answers
488
views
Multi-threaded domain status checking in Java
I'm tinkering with the idea of crafting a search engine in my spare time. More of a learning experience than anything at this point, but still a project. A key aspect of this system is checking ...
2
votes
1
answer
108
views
Fast search for the longest repeating substrings in large text (Rev.2)
This is the second iteration of the Fast search for the longest repeating substrings in large text code review. Special thanks goes to G. Sliepen who conducted the first review.
Functional ...
2
votes
3
answers
384
views
Most effective search algorithm for guessing list of strings via function returning bool if substring is in list using Python
I trying to figure out the most effective way to accomplish this task:
A function, check(), contains a list of strings. Calling the function with a string as ...
156
votes
20
answers
32k
views
Searching an element in a sorted array
I was applying for a position, and they asked me to complete a coding problem for them. I did so and submitted it, but I later found out I was rejected from the position. Anyways, I have an eclectic ...
39
votes
5
answers
7k
views
JavaScript binary search
I wrote an implementation of binary search in JavaScript earlier for kicks, but I noticed my version was significantly different than those found on Google. Here is an example of binary search I found ...
32
votes
4
answers
78k
views
A* search algorithm
NodeData stores all information of the node needed by the AStar
algorithm. This information includes the value of ...
30
votes
8
answers
50k
views
Find all the missing number(s)
Recently I've attended an interview, where I faced the below question:
Question: "There is an sorted array. You need to find all the missing numbers. Write the complete code, without using any ...
19
votes
4
answers
1k
views
Name Filtering using a Trie
This question suggests a different (improved?) implementation for searching/filtering names based on a search query. This is based on the question here: Name filtering in Java
A Trie allows the ...
12
votes
4
answers
8k
views
strstr() implementation
In this strstr implementation, I am basically skipping the already matched and checked characters with an if else condition. Is ...
11
votes
2
answers
1k
views
Finding an element in multiple sorted lists efficiently
I have \$k\$ sorted Lists, each of size \$n\$. Currently I have hard-coded 5 sorted Lists each of size 3, but in general that is ...
11
votes
2
answers
22k
views
Powershell search millions of files as fast as possible
I once asked a similar question but in C#. Now I have the same problem in powershell..
What is the fastest way, to search files newer than 15 minutes, in a file system with more than 1 million files?
...
11
votes
2
answers
14k
views
Searching a Word Document from Excel
Today I created a script in Excel that migrates data from a specific Word document and copies a portion of it to a cell in Excel (the date to be specific).
The file input is
Last name, First Name, ...
11
votes
1
answer
1k
views
Karp-Rabin with bitwise hash
As a Rags-to-Riches re-implementation of the Karp-Rabin question here, from @tsleyson, I thought it would be interesting to understand the algorithm better, and to use bitwise-shifting instead of ...
10
votes
2
answers
508
views
Naive implementation of KMP algorithm
After reading this answer to the question "High execution time to count overlapping substrings", I decided to implement the suggested Knuth-Morris-Pratt (KMP) algorithm. I used the pseudo-code listed ...
10
votes
1
answer
372
views
Fuzzy grep for fuzzy bears in pure Python
I am aware of the Python modules galore to do this, but this was partially a learning experience and partially all the functionality I need and no more.
I'm writing a simple interpreter for a Forth-...
7
votes
2
answers
1k
views
Find and rename all png files
I have such problem : find all png files to disk and rename them as I did:
...
6
votes
2
answers
6k
views
Find a best fuzzy match for a string
I am trying to find a best match for a name within a list of names.
I came up with the below code, which works, but I feel that the creation of the intermediate ...
6
votes
1
answer
126
views
Bash command helper in C++
I'm writing a program to help with remembering complex bash commands. On invoking the program, it asks for a description of the desired operation, e.g., "increase volume" or "find orphaned packages", ...
6
votes
2
answers
201
views
Name filtering in Java
I have a search box for searching for people in a list of names.
Here is the code that runs every time the query changes. I could not find anything open-sourced for this, so I wanted to make sure ...
6
votes
1
answer
208
views
Randomizing and mutating algo class - functionality
See Randomizing and mutating algo class - style
I'm looking for a review of the functionality of this code, answers to the above question which also describes the code use focus on style instead.
...
5
votes
1
answer
166
views
Text search in Python
Whilst self-studying algorithms, I came across the Karp-Rabin rolling hash search algorithm here. I decided to have a go at implementing it in Python:
For ease of reading; the data-structure ...
5
votes
3
answers
11k
views
Search in a big dictionary Python
I have a big Python dictionary with more then 150,000 keys every key has list value. This dictionary contains infinitive words as key and all grammatical forms of these words as values:
...
5
votes
2
answers
319
views
Randomizing and mutating algo class - style
I've updated this question to be about code style only, as all of it's answered focused on this aspect. For the codes function, see Randomizing and mutating algo class - functionality
...
5
votes
2
answers
130
views
Knuth-Morris-Pratt over a source of indeterminate length
Please review my generic implementation of the Knuth-Morris-Pratt algorithm. Its modified to search a source of indeterminate length in a memory efficient fashion.
...
5
votes
2
answers
7k
views
Search word in multiple files
I am writing a brute-force method to search for a word. Please review my code and tell me how I can improve it.
...
4
votes
0
answers
168
views
Improved Knuth-Morris-Pratt over a source of indeterminate length
Following the successful review of my previous implementation.
Please review my new, generic implementation of the Knuth-Morris-Pratt algorithm. Its modified to search a source of indeterminate ...
4
votes
4
answers
5k
views
Wildcard search in C
In the effort to improve my C knowledge, I tried creating a wildcard search function:
...
3
votes
1
answer
99
views
Fast search for the longest repeating substrings in large text (Rev.4)
This is the forth iteration of the Fast search for the longest repeating substrings in large text (Rev.3) code review. Special thanks goes to G. Sliepen who conducted all the reviews.
Functional ...
3
votes
1
answer
3k
views
Grid walk problem
CodeEval's "Grid Walk" problem is as follows:
There is a monkey which can walk around on a planar grid. The monkey can move one space at a time left, right, up or down. That is, from (x, y) the ...
3
votes
1
answer
286
views
String.IndexOfAny(string, string[]) (lowest position for group of needles in haystack)
This is a follow-up to this question with bug fixes, question and code improvements from @dfhwze, @PieterWitvoet, @HenrikHansen, @t3chb0t. I am still hoping for an improved approach or algorithm ...
3
votes
1
answer
514
views
Typeahead Talent Buddy
Problem is Talent Buddy.
Your task is to
write a function that prints to the standard output (stdout) for each query the user name that matches the query
if there are multiple user names ...
3
votes
1
answer
570
views
Knuth–Morris–Pratt string search algorithm
I finally think I've implemented the Knuth–Morris–Pratt string search algorithm correctly, now time for that lovely criticism that causes me to learn! The code doesn't look all that pretty however it ...
3
votes
3
answers
688
views
Case insensitive sub-string search
I found myself in a need of a function that checks whether a string is a sub-string of another string, in a case-insensitive manner. I found that there's no standard function to do this, so I wrote my ...
3
votes
2
answers
1k
views
Search algorithms in julia
I've been trying to implement the basic search algorithms: Sequential search for ordered and unordered arrays and the binary search algorithms, as part of a package.
So, this is the implementation:
<...
2
votes
2
answers
115
views
Search through each file in a directory, list number of instances of searched string
I am trying to open each file listed in Sheet2 Column A, search for a string of text located in Sheet3 Cell B1, list the number of instances this string appears in each particular file in Sheet3, and ...
2
votes
2
answers
142
views
Repository searching code duplication
A followup question to this: IQueryable Extensions working on expression for collection property
I am working on a project for a family member which involves the use of a database and a repository, ...
2
votes
2
answers
1k
views
A set of names and a request with asterisks
I have a set of names and a request with asterisks. An asterisk can be replaced with any letter.
For example, there is a set of names: hasad, ahmed, fizo. And there are a few sample requests: hasad, ...
2
votes
2
answers
1k
views
Best C# implementation of IndexOfAny(string, params string[])
Follow-Up question
.Net provides String.IndexOfAny(string, char[]) but not String.IndexOfAny(string, string[]).
The existing ...
2
votes
2
answers
291
views
Run dir scan as fast and efficient as possible / clean code
I'm not a very experience python programmer. But I want to make my code as fast and efficient as possible as well as write it clean and therefore got the advice to share it here. So I'm having the ...
2
votes
2
answers
232
views
A linear search implementation for any data type in C
I performed an "experiment" to test my understanding of pointers in C. I decided to write a linear search function that can work on any array provided there is an existing function to compare the ...
2
votes
1
answer
136
views
Fast search for the longest repeating substrings in large text (Rev.3)
This is the third iteration of the Fast search for the longest repeating substrings in large text (Rev.2) code review. Special thanks goes to G. Sliepen who conducted the first two reviews.
Functional ...
-2
votes
2
answers
407
views
Fastest string search algorithm invented by me. It is called ""Choudhary String Search Algorithm""
I have invented the fastest string search algorithm. It is called ""Choudhary String Search Algorithm (choudharyStringSearchAlgorithm)"". I have compared my algorithm with Brute ...