21
votes
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 ...
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:
...
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:
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 :
...
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 ...
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) ...
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, ...
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 ...
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 ...
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, ...
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 ...
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 ...
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
...
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} = ...
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 ...
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 ...
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 ...
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.
...
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 ...
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:
...
7
votes
Accepted
Copy file with text replacement
std::getline and std::string are in the <string> header, so we need to include that.
...
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 ...
6
votes
Accepted
"Vc" as in Vancouver, or Valencia?
[Char] is usually written as String.
You have a redundant base case: nameMatch [] [].
The ...
6
votes
Accepted
Let's play Find that File
Bug
In the constructor, matchingRegex must be initialized before calling getAllFiles(root);, otherwise a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
search × 382java × 82
performance × 81
algorithm × 81
python × 72
strings × 61
c++ × 46
c# × 44
javascript × 37
python-3.x × 25
array × 24
beginner × 22
c × 21
file × 20
binary-search × 18
tree × 16
php × 14
ruby × 13
sorting × 13
programming-challenge × 11
file-system × 10
object-oriented × 9
vba × 9
interview-questions × 9
sql × 8