Hot answers tagged

21 votes

Search a big (13 GB) Outlook PST file

I would assume that this ...
Heslacher's user avatar
  • 50.3k
17 votes

Search a big (13 GB) Outlook PST file

COM interop is in itself a performance hit, but even when accessing it through COM (e.g. in VBA), the Outlook type library / object model is notoriously, painfully slow. If performance is a ...
Mathieu Guindon's user avatar
17 votes

C++ implementation of depth-first search

What further improvements can I make to this code? The code is rather bad - the site you read it from tends to have lots of bad/amateur articles. The graph class: ...
ALX23z's user avatar
  • 2,253
14 votes
Accepted

Java TreeMap.floorKey() equivalent for std::map

Headers and namespaces The function is missing a definition of map. This is probably what you want: ...
Toby Speight's user avatar
13 votes

Fastest string search algorithm invented by me. It is called ""Choudhary String Search Algorithm""

Maybe your algorithm is really fast, but this site isn't about algorithm review, it's about code review. And a "fastest string search algorithm" should come in a software package of an ...
Ralf Kleberhoff's user avatar
12 votes
Accepted

Filtering a list for certain strings

I took the liberty of rewriting most of this from scratch for a few reasons. First, this very difficult to actually test. All your embedded if statements... oh my! Second it's also difficult to add ...
enderland's user avatar
  • 1,736
12 votes
Accepted

Searching for a specific object in an ArrayList

Your code is very wet (the opposite of DRY). It repeats a lot. Let's start with what you're trying to achieve: You have an ArrayList of ...
Dan's user avatar
  • 3,753
12 votes

C++ implementation of depth-first search

Disagreement I have to disagree with @ALX23z blanket statement that using std::map is bad idea. There is a lot more to it than that (if the graph was sparse the map ...
Martin York's user avatar
  • 93.9k
11 votes

Read file with over 300k words and filter through appropriate filter to return list of matching words

First off I'd change how you are making char1filter. Here's what I'd do differently: Remove the is True as it's implied. Change ...
Peilonrayz's user avatar
  • 42.4k
10 votes

Composing and executing a customer search

Not sure if you know how dangerous omitting braces for if statements can be. Do you know what happens here : ...
Heslacher's user avatar
  • 50.3k
10 votes

C++ implementation of depth-first search

I've assumed here the OP is performing DFS on undirected graphs - if not only my second point is valid. There are several other answers here suggesting better coding practices and more efficient ...
Chaos's user avatar
  • 201
9 votes
Accepted

Search in a JSON structure after a key

Your function name is not very meaningful in that; a) there is nothing to say values returned in the array will be objects (since you are just grabbing whatever data is stored for the key), and b) ...
Mike Brant's user avatar
  • 9,588
9 votes
Accepted

Find and rename all png files

First of all you should rename your function, it doesn't perform just a search then DirSearch() is not appropriate. What about, for example, ...
Adriano Repetti's user avatar
9 votes

Find all words that satisfy unknown letters (Hangman)

The solution would indeed be much simpler using regular expressions. The trick is to build the regular expression dynamically, using a negated character class like ...
200_success's user avatar
9 votes

Java TreeMap.floorKey() equivalent for std::map

Your code is obviously wrong: template <typename key,typename value> This line suggests that the code works for arbitrary maps, yet you require an ...
Roland Illig's user avatar
  • 21.2k
8 votes

Bash command helper in C

* or [] There isn't really a definitive time when you should and shouldn't use pointers or arrays (at least not that I know of). However, I generally only use arrays for: Large buffers. For example, ...
SirPython's user avatar
  • 13.3k
8 votes
Accepted

Binary search function in C#

This code is wrong in a great many ways. public int BinarySearchIterative(int[]inputArray, int Key) { The name describes how the code is implemented, not what it ...
Eric Lippert's user avatar
  • 14.7k
8 votes

Searching for a specific object in an ArrayList

there is a redundant semi-colon ';' at the end of every if and at the end of the loop (basically after closing curly braces) code to the inteface: the method should accept an argument of ...
Sharon Ben Asher's user avatar
8 votes
Accepted

DFS in a binary tree

This code is pretty much the most efficient it can be, so I will add some pointers on the coding style and convention. Instead of calling your Binary Search Tree class a BST, define it as ...
Anshul Goyal's user avatar
7 votes
Accepted

Finding Egyptian fractions with A* search

There's a bug in is_solution: >>> is_solution((2, 3, 6), 4) False even though $$ {1\over2} + {1\over3} + {1\over6} = ...
Gareth Rees's user avatar
  • 49.6k
7 votes
Accepted

Scanning multiple huge files in Python

Some smaller adjustments By just quickly glancing on the code I would suggest the following actions: Move the opening of the output file to where you open the ...
holroy's user avatar
  • 11.5k
7 votes

Product search script Object Oriented PHP

Security: SQl Injection You use prepared statements, which is great. But you still put variables directly into SQL queries, which makes you vulnerable to SQL injection via ...
tim's user avatar
  • 25.1k
7 votes
Accepted

Read file with over 300k words and filter through appropriate filter to return list of matching words

In addition to the suggestions made by Joe Wallis, here’s one that will help performance: Don’t store the entire file in a tuple. This requires Python to store the entire file in memory, which is ...
alexwlchan's user avatar
  • 8,485
7 votes
Accepted

Detect if string contains more than 1 period

Optimize for maintainability first Is the complexity of your function really needed? The functionality can be implemented in one line using only standard-library algorithms. ...
5gon12eder's user avatar
  • 4,250
7 votes
Accepted

Find a best fuzzy match for a string

You should take advantage of the key argument to max(): The key argument specifies a one-argument ordering function like that ...
200_success's user avatar
7 votes
Accepted

Sum of 2 numbers in an array

Since there's no real review to do and we're apparently just posting solutions... here's a simple O(n) time O(1) space one: ...
superb rain's user avatar
  • 3,981
7 votes
Accepted

Copy file with text replacement

std::getline and std::string are in the <string> header, so we need to include that. ...
user673679's user avatar
  • 11.4k
6 votes
Accepted

Generic domain independent Monte Carlo Tree Search methods library

It's really nice to see code like this up for review. I have had to do some reading up on what the Monte Carlo tree search actually is, but I have enough of an idea now that I can see where you have ...
rolfl's user avatar
  • 97.3k
6 votes
Accepted

"Vc" as in Vancouver, or Valencia?

[Char] is usually written as String. You have a redundant base case: nameMatch [] []. The ...
200_success's user avatar
6 votes
Accepted

Let's play Find that File

Bug In the constructor, matchingRegex must be initialized before calling getAllFiles(root);, otherwise a ...
Antot's user avatar
  • 3,637

Only top scored, non community-wiki answers of a minimum length are eligible