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
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 ...
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
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 ...
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
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
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
Find all strings in list which have keywords in it from another list
Your general coding style is very readable.
You stick to PEP8 and your function and the variables are named reasonably.
You could optimize your code by using the built-in functions ...
6
votes
Functionally find the index of the minimum value in an array
I think there's no need to use the match keyword here because you're not actually doing any pattern matching, only shadowing the name ...
6
votes
Go grep command clone
The thing is, even so, standard grep still gets results faster by an amount of 60 % less processing time
For more information on what makes GNU grep fast, read this by the original author.
Here is ...
6
votes
Accepted
Filter for CANbus frames
Cleaner and clearer it can certainly be:
your function is called isFrameMatchedByFilter but returns true if there is no filter in the filter list: does that mean ...
6
votes
Best C# implementation of IndexOfAny(string, params string[])
Review
Don't use abbreviated variable names s, curAns and posAns; use self describing names:...
6
votes
C-based hash matching cracker
stderr
I don't know the requirements of the problem, but in a real program, error messages should be written to stderr:
...
6
votes
Accepted
Javascript - Find a deepest node in a binary tree
Here are my thoughts:
Don't mutate function parameters unless there is good reason to do so.
node.depth = level;
The above statement basically breaks the ...
6
votes
Counting the number of patterns that exist in a particular string
The current time complexity I reckon is O(N*M) where N = elems of pattern, M = elems of word.
I'd say O(NM) where N = the total size (sum of lengths) of patterns, M = length of word. There is a ...
6
votes
Accepted
Optimizing a node search method given a 2-D spatial point
flags
I appreciate the clarity of this, thank you.
found = True
return cout_index, found
That is, I know exactly what the return ...
6
votes
Accepted
A search function that searches for a contact inside a vector
Keeping in mind that it is impossible to give good answers, or a good review, without a clear context of what the code is for or how it is going to be used. A single member function—not even a full ...
5
votes
Searching an element in a sorted array
Your solution works, yet, as said in previous answers, it runs in worst case linear time. You can reduce it to any-case logarithmic by rewriting two functions in the C++ standard library to C: namely, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
search × 392java × 84
performance × 84
algorithm × 83
python × 72
strings × 64
c++ × 54
c# × 44
javascript × 37
python-3.x × 25
array × 25
beginner × 22
c × 22
file × 20
binary-search × 19
tree × 16
php × 14
ruby × 13
sorting × 13
programming-challenge × 11
file-system × 10
object-oriented × 9
interview-questions × 9
sql × 8
vba × 8