Top "Algorithm" questions

An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem.

What exactly does big Ө notation represent?

I'm really confused about the differences between big O, big Omega, and big Theta notation. I understand that big O …

algorithm computer-science big-o notation big-theta
Fastest way to flatten / un-flatten nested JSON objects

I threw some code together to flatten and un-flatten complex/nested JSON objects. It works, but it's a bit slow (…

javascript algorithm
Getting the closest string match

I need a way to compare multiple strings to a test string and return the string that closely resembles it: …

algorithm language-agnostic string-comparison levenshtein-distance
How can I sort a std::map first by value, then by key?

I need to sort a std::map by value, then by key. The map contains data like the following: 1 realistically 8 …

c++ algorithm sorting dictionary key
Why do we check up to the square root of a prime number to determine if it is prime?

To test whether a number is prime or not, why do we have to test whether it is divisible only …

algorithm primes primality-test
Best way to randomize an array with .NET

What is the best way to randomize an array of strings with .NET? My array contains about 500 strings and I'd …

c# .net algorithm sorting random
Python Brute Force algorithm

I need to generate every possible combination from a given charset to a given range. Like, charset=list(map(str,"…

python algorithm brute-force
Why doesn't Dijkstra's algorithm work for negative weight edges?

Can somebody tell me why Dijkstra's algorithm for single source shortest path assumes that the edges must be non-negative. I …

algorithm shortest-path dijkstra
Count number of 1's in binary representation

Efficient way to count number of 1s in the binary representation of a number in O(1) if you have enough …

algorithm binary
Calculate mean and standard deviation from a vector of samples in C++ using Boost

Is there a way to calculate mean and standard deviation for a vector containing samples using Boost? Or do I …

c++ algorithm boost statistics mean