This tag is for questions about search algorithms, tools, and technologies.

learn more… | top users | synonyms

6
votes
2answers
69 views

Searching for files in a specified directory

I am currently writing a program that allows me to search for files in a user-specified directory. My current code is as follows: ...
0
votes
0answers
26 views

how can i search text file in another text file? [closed]

I have been trying to get two text files to search trough each other line by line. Once has a bunch of words (around 20 words, one per line). for example : "getting", "wake up" , "do not use" . And ...
1
vote
0answers
27 views

Binary search with heurisitcs or something else

Currently I'm using a binary search algorithm to search an index of a tree that represents an XML file. Can I use heuristics to improve the search? What can I do to improve this search function? ...
10
votes
4answers
427 views

Find byte[] in byte[] with Java

I made a search method because I want to use binary data like PNG files. The point of this is to be able to find strings like IEND in a PNG file. I think it works ...
2
votes
0answers
36 views

The most efficient algorithm for finding treeview's node by string

I have a string variable that holds text loaded from database. When program loads, I should find the node in treeview control with matching label text and select it. I have found several solutions ...
5
votes
1answer
72 views

Searching in a sorted 2D matrix

If I was at an interview, and wrote this code, what would you think? Please be brutal. Time it took to wrote it: 13 minutes Problem: Write an efficient algorithm that searches for a value in an ...
2
votes
1answer
59 views

Search filter list using jQuery

I looked at a search filter code code and edited it to catered to my functional needs. I understood most of the JavaScript except the extend method bit. Can someone explain that? Also, is this the ...
6
votes
1answer
52 views

indexOf() and Boyer Moore methods

I have a method I created which is a custom indexOf(). This code seems ugly to me so I was wondering if anyone could recommend a cleaner and perhaps faster ...
7
votes
5answers
720 views

Efficient pathfinding without heuristics?

Part of my program is a variable-sized set of Star Systems randomly linked by Warp Points. I have an A* algorithm working rather well in the grid, but the random warp point links mean that even though ...
7
votes
5answers
518 views

Fast way of searching for a string in a text file

I have written this code to search for a string in a .txt file. Is it possible to optimize the code so that it searches for the string in fastest manner possible? ...
5
votes
1answer
67 views

My attempt at a weighted search in JavaScript

I tried to make a weighted search function in JavaScript. I've been improving my JS lately but still not sure about some best practices, wondering if there's any improvements I could make, or if I've ...
6
votes
3answers
116 views

How to extract elements from multiple sorted list efficiently?

Problem Statement:- I was ask this interview question recently.. I was able to come up with the below code only which runs in O(k log n)- Given k <= n sorted arrays each of size n, there exists ...
9
votes
2answers
155 views

Efficiently find an element in multiple sorted lists

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 configurable. I would like to search for single element in each of the k Lists ...
6
votes
1answer
118 views

AngularJs and Google Bot experiment

I have learned the question of solving Angular app optimization for search engines, and was frustrated that the most recommended option is prerendering html. After some time spent, I suggested to ...
8
votes
3answers
278 views

Scrabble algorithm review and performance suggestions

After finishing Project Euler 24, I decided to make a scrabble type of application using /usr/lib/dict as my dictionary what I cat that into a word file. It does take a few seconds, and the dictionary ...
3
votes
2answers
53 views

Searching and comparing a record

I am still a beginner in C++ and I am always curious about good/best coding methods. Let's say I have a program which allows a users to edit the salary of a employee. The system will prompt the ...
6
votes
1answer
783 views

A* search algorithm

A* search algorithm. Looking for reviews on optimization, accuracy and best practices. ...
4
votes
2answers
121 views

Simple fuzzy text search algorithm

Basically, this code takes a keyword and an array of strings, then sorts them based on two things: the number of characters shared with the key, and the distance between them.(As a side note, would ...
28
votes
11answers
3k views

Searching in an array in less than O(n) time

I have an array where each element is either one less or one greater than the preceding element \$\{x_i = x_{i-1} \pm 1\}\$. I wish to find an element in it in less than \$O(n)\$ time. I've ...
3
votes
1answer
100 views

How to improve this session cache to search faster

I have this code which will store user session credentials: ...
2
votes
3answers
159 views

Improving speed of word search algorithm

I've been working on this word search algorithm and had some issues about its speed. It kinda looks like it takes a little too much time. If anyone could offer suggestions on making this better and ...
2
votes
1answer
137 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 ...
6
votes
1answer
159 views

Is this implementation of binary search correct?

Is this implementation of binary search correct? Any special or edge cases that I missed out? Maybe it should be optimized for elements that are less than the first element of the array or greater ...
1
vote
0answers
58 views

How to increase concision and performance in a function to retrieve sentences where keywords match?

I'm building a text search system for a web application in PHP. I wrote this function that gets the sentences of the text which contains the keywords used by the user and also highlight them (well, ...
0
votes
1answer
25 views

Highlight a pattern found

I made a small web application with a search box. I wanted to highlight the words found in the search. ...
1
vote
1answer
134 views

Wildcard search in C version 2

A few days ago, I posted my version of a wildcard search algorithm, which you can see here: Wildcard search in C Today I'm showing version 2. I didn't want to make it in the same post because the ...
3
votes
4answers
213 views

Wildcard search in C

In the effort to improve my C knowledge, I tried creating a wildcard search function: ...
3
votes
5answers
1k views

Writing out names of files on local C drive to a text document

This program writes out all the files in the current directory level to a text file, outputs an array of sub-directories at the current level, then repeats this process until there are no more ...
1
vote
3answers
2k views

searching word or phrase among files

I've written a program: ...
0
votes
2answers
46 views

Please help me modularize this class

The code works but I want to split it into functions and make it more reusable. The way it is now, the code is not reusable. I want the parts which replaces the query string and the part that ...
2
votes
1answer
131 views

Use search query to find and modify files in directory

I've made a program that goes through your download directory (or any other directory; you just have to change the path) and finds the files that matches your query then asks you to rename or remove ...
2
votes
1answer
882 views

Recursive find function in JavaScript / jQuery

I wrote the following code as a way of plucking data from a n-depth JavaScript object. It works a charm and even appends the parents of the the found item. I was just wondering if you guys had any ...
1
vote
0answers
36 views

String Matching

I recently came across a lecture on DFA. I tried to use it to determine whether a given 'search string' is found in the 'input string'. Please tell me if there is a better way ...
1
vote
0answers
225 views

HashSet add and search functions [closed]

This is my first time implementing a hash set and I need your help. I know I didn't implemenet the operator= and the copy constructor(that's because I don't know how to), and the remove function. I ...
5
votes
1answer
345 views

Java alphabeta search

Is this code correct? This code was adapted from this alphabeta pseudocode. AlphaBeta search is often mentioned but getting the code 100% correct is tricky. ...
1
vote
2answers
292 views

Bisection search game

I'm starting to learn Python and am trying to optimize this bisection search game. ...
1
vote
1answer
107 views

Any mistakes in the following Java program in solving this task from ACM Timus [closed]

The problem description is from ACM Timus Online Judge. (1930. Ivan's Car) My first idea is using BFS. But it keeps getting Wrong Answer at Test 6. Any hints to solve this? The following is my Java ...
3
votes
0answers
420 views

Moving from Solr (Sunspot) to ElasticSearch (Tire), Review needed

I would like a review regarding the following code in which I index and search the City model. Currently both solr (with sunspot gem) and elaticsearch (with the tire gem) are show. I am migrating from ...
4
votes
2answers
576 views

ElasticSearch, Tire - refactor autocomplete method for multiple resources

I am using ElasticSearch and Tire for search in my app across all models. I would like to refactor autocomplete method because it looks to complex for me. Am I using a good pattern for searching ...
0
votes
3answers
742 views

Searching for an element in a 2D array

For example, given a 2D array (a matrix): {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}} What are the solutions to find a number, such as 6? Here's the code I ...
3
votes
0answers
135 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. ...
6
votes
2answers
227 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 Review: C++ Algo - Function ...
5
votes
2answers
471 views

Golang solution to Project Euler #81 (min path through a matrix)

Project Euler problem 81 asks: In the 5 by 5 matrix below, ...
13
votes
7answers
16k views

Finding repeating numbers in an array

I want to search through an array of n numbers and find the numbers that are repeated. So far I have this code, which does the job, but I find it to be a rather cumbersome method, but I can't seem to ...
2
votes
1answer
133 views

Shifting Paths problem (Code Jam)

I was trying, just for fun, to solve http://code.google.com/codejam/contest/dashboard?c=2075486#s=p4 I can easily solve the small set, but I struggle to solve the big one (my implementation would ...
3
votes
1answer
107 views

Kindly review this class

What I can think of improving is: Show stack on screen to fail gracefully i.e. improved catch part of try..catch Make the try part shorter to improve readability Make imports with * to improve ...
3
votes
2answers
278 views

UVA 10474 - “Where is the marble?” time limit

I have a problem from UVA online judge here. I have read it tons of times, and as they said, I have to get the answer really fast. I have used a binary search and ...
5
votes
1answer
2k views

Java 2d array nested loops

Okay, So I have this method I made that searches a 2d array of user input column length and row length comprised of integers. The method is suppose to find 4 alike numbers in rows, columns, and both ...
3
votes
1answer
75 views

Improve search keyword

I've been given the following PHP code: ...