The search tag has no wiki summary.
0
votes
0answers
16 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
(display "Enter input ...
0
votes
0answers
37 views
HashSet add and search functions
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 ...
1
vote
1answer
58 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 ...
2
votes
0answers
142 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
274 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
118 views
Given an 2D array which is row and column wise sorted. What is the efficient way to search for an element?
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? say 6.
Here's the code I tried using Binary search method -
(code ...
1
vote
0answers
106 views
Review: C++ Algo - Function
See Review: C++ Algo - Style
I'm looking for a review of the function of this code, answers to the above question which also describes the code use focus on style instead.
Below is the updated code ...
3
votes
2answers
193 views
Review: C++ Algo - Style
Can this code be reviewed?
I've updated this question to be about code style only, as all of its answered focused on this aspect. For the codes function, see Review: C++ Algo - Function
'algo' is an ...
3
votes
1answer
248 views
Golang solution to Project Euler problem #81
Below is a Go solution to the problem 81 in project euler using uniform cost search to build a search tree. It works on the toy small problem but on the 80x80 matrix it runs out of space. Could anyone ...
5
votes
5answers
1k 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
89 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
98 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 ...
4
votes
1answer
984 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
65 views
Improve search keyword
I've been given the following PHP code:
if(empty($search)){
$_SESSION['keyword_exists'] = "no";
}else{
if(isset($_SESSION['old_keyword']) && $_SESSION['old_keyword'] != ...
1
vote
1answer
41 views
Regex Refinement
I'm trying to parse addresses out of blocks of text, and have the following expression to do so:
/\d+\s(?:[sewnSEWN]\.?\s)?[\d\w]+\s(?:(?:[\d\w]+\s){0,3})?\w+\.?/
It will currently parse addresses ...
2
votes
3answers
594 views
C++ Code Critique: Sliding block puzzle, A*
I'm a beginner programmer and Im hoping someone would be willing to take a look at my code and tell me how to improve my coding style and development approach. Sorry about not commenting, I will try ...
2
votes
3answers
236 views
Finding the highest values a and b from an array
I struggled a short while to make this work, so I'm wondering if there are any smarter ways for finding the highest of two values per array element? Uh, hard to explain by words, but by code its easy:
...
2
votes
1answer
182 views
need help improving mysql and php filter code
I only recently started coding so I know my code is not very good, but i would really appreciate any help on improving my code.
my database table looks like this
game_id |title |developer ...
5
votes
1answer
2k views
Implementation of Kosaraju's algorithm for strongly connected components
To learn and practice coding in C++, I wrote an implementation of Kosaraju's two-pass algorithm for computing the strongly connected components in a directed graph, using depth-first search.
This was ...
0
votes
1answer
73 views
Word lookup code optimization
I have a java class which accepts some data and reads it in as a raster of characters x by y. The class is used then to look for occurrences of a certain word in any direction of the raster and store ...
3
votes
1answer
299 views
Refactoring binary search algorithm in Ruby
I wrote the binary search algorithm with Ruby, the code is below. The question is if there's any way to make it look cleaner?
def binary_search(sample_array, x, l, r)
mid = (l + r)/2
return -1 if ...
3
votes
2answers
122 views
Is there a better, more object oriented way to write this Finder method?
I have several lists of objects which are stored in different locations, based on what they are and who needs them - the system, or the user, for example. There are times where I am only given an ID ...
0
votes
1answer
608 views
Source-code used to find specific objects in the list. “Where is the bug?” [closed]
Below is given my source code. It´s compiled. I already posted questions that were partly related to the task solved by this code. Now I have a complete project.
The task is the following: there are ...
4
votes
4answers
849 views
searching a value from one csv file in another csv file - Python
I am writing a script that takes one csv file searches a value in another csv file then writes an output depending on the result it finds.
I have been using python's csv. Distreader and writer, I ...
2
votes
1answer
207 views
binary searching strings
/*I wrote a quick and dirty program to binary search an ordered array (list) of C style strings. For example - {“1”, “12”, “23”, “124”} etc (though my input set is actually much different).
NOTE:
...
4
votes
6answers
3k views
Efficient Binary Search
My implementation:
Array.prototype.binarySearchFast = function(search) {
var size = this.length,
high = size -1,
low = 0;
while (high > low) {
if (this[low] === search) ...
1
vote
0answers
314 views
Optimizing a search for list of artists in iTunes library
I'm trying to get a list of all artists on an iPhone / iPod touch music library. The best way I've found has been to group by artists (the convenience constructor on MPMediaQuery) and to iterate over ...
2
votes
1answer
439 views
Review Request: Python code that searches query words in a given text
I have this code which looks for query words in a given text. I preprocess the give text and store it in an inverted-index (dictionary with word as key and position in text as value). Searching for a ...
4
votes
3answers
2k views
Is this a reasonable Trie implementation?
http://en.wikipedia.org/wiki/Trie
The basic idea is to support fast searches via prefix matching. In my implementation, I allow each node to store all of the words that match its given prefix, and ...
