Skip to main content
21 votes

Search a big (13 GB) Outlook PST file

I would assume that this ...
Heslacher's user avatar
  • 50.4k
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,389
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
  • 81.7k
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

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,748
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 ...
Loki Astari's user avatar
  • 96.6k
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

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.9k
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,638
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.4k
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

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,300
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,991
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.9k
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 ...
Richard Neumann's user avatar
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 ...
TheQuickBrownFox's user avatar
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 ...
esote's user avatar
  • 3,770
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 ...
papagaga's user avatar
  • 5,767
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:...
dfhwze's user avatar
  • 13.9k
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: ...
alx - recommends codidact's user avatar
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 ...
ggorlen's user avatar
  • 3,987
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 ...
user555045's user avatar
  • 10.7k
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 ...
J_H's user avatar
  • 35k
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 ...
indi's user avatar
  • 13.7k
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, ...
coderodde's user avatar
  • 29.8k

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