Update: Please read this question in the context of design principles, elegance, expression of intent, and especially the "signals" sent to other programmers by design choices.
I have two "views" of a set of objects. One is a dictionary/map indexing the objects by a string value. The other is a dictionary/map indexing the objects by an ...
This one is a bit tedious in as far as explaining, so here goes. I'm essentially populating a tableView on the iPhone with multiple sections, and potentially multiple rows per section. To my understanding, it's best to have an array of arrays so that you can simply determine how many sections one has by sending a message to the top level...
I have an array (arr) of elements, and a function (f) that takes 2 elements and returns a number.
I need a permutation of the array, such that f(arr[i], arr[i+1]) is as little as possible for each i in arr. (and it should loop, ie. it should also minimize f(arr[arr.length - 1], arr[0]))
Also, f works sort of like a distance, so f(a,b) ...
Very simply, what is tail-call optimization? More specifically, Can anyone show some small code snippets where it could be applied, and where not, with an explanation of why?
...
I want to perform some empirical trade-off's to assess the performance of applications written in a number of different languages on a Linux platform. Are there standard algorithms that typically used for this purpose?
...
I am trying to test the likelihood that a particular clustering of data has occurred by chance. A robust way to do this is Monte Carlo simulation, in which the associations between data and groups are randomly reassigned a large number of times (e.g. 10,000), and a metric of clustering is used to compare the actual data with the simulat...
I am looking for an efficient means to partially check the integrity of "large" data sets over a slow transfer medium. This seems like a common problem as file sizes grow out of proportion to transfer rates.
For example, for concrete numbers, a terabyte of data over USB2. Checking that this data is still valid by reading every byte in...
Pretty much as the question asks. Answers preferably in pseudo code and referenced. The correct answer should value speed over simplicity.
...
I'm trying to create an algorithm in C# which produces the following output strings:
AAAA
AAAB
AAAC
...and so on...
ZZZX
ZZZY
ZZZZ
What is the best way to accomplish this?
public static IEnumerable<string> GetWords()
{
//Perform algorithm
yield return word;
}
...
Given a list of sets:
S_1 : [ 1, 2, 3, 4 ]
S_2 : [ 3, 4, 5, 6, 7 ]
S_3 : [ 8, 9, 10, 11 ]
S_4 : [ 1, 8, 12, 13 ]
S_5 : [ 6, 7, 14, 15, 16, 17 ]
What the most efficient way to merge all sets that share at least 2 elements? I suppose this is similar to a connected components problem. So the result would be:
[ 1, 2, 3, 4, 5, 6, 7, 1...
Given two sets A and B, what is the common algorithm used to find their union, and what is it's running time?
My intuition:
a = set((1, 2, 3))
b = set((2, 3, 5))
union = set()
for el in a:
union.add(el)
for el in b:
union.add(el)
Add checks for a collision, which is O(1), and then adds the element, which is (??). This is do...
It's been awhile since my algorithms class in school, so forgive me if my terminology is not exact.
I have a series of actions that, when run, produces some desired state (it's basically a set of steps to reproduce a bug, but that doesn't matter for the sake of this question).
My goal is to find the shortest series of steps that stil...
I want to learn algorithms using some very basic simple tutorials. Are there any out there? I have heard of recursion and stuff and I would like to get good at it. Any help would be appreciated.
...
Are the formulas represented in an AST then recalculated using a design pattern like the Visitor pattern? How would you go about reproducing the recalculation process in code?
...
I am new to culling. On a first glance, it seems that most occlusion culling algorithms are object-level, not examining single meshes, which would be practical for game rendering.
What I am looking for is an algorithm that culls all meshes within a single object that are occluded for a given viewpoint, with high accuracy. It needs to be...
Say we have normal distribution n(x): mean=0 and \int_{-a}^{a} n(x) = P.
What is the easiest way to compute standard deviation of such distribution? May be there are standard libraries for python or C, that are suitable for that task?
...
Hi all,
As I continue my quest of learning functional programming, I've come
to wonder if there may be alternatives to my default "procedural" way
of thinking. To be more specific, I'm looking at a function I
wrote. Here is what it does:
Swap two elements of an unordered list of numbers, such that one of the elements
is now in the r...
I'm looking to generate a random number and issue it to a table in a database for a particular user_id. The catch is, the same number can't be used twice. There's a million ways to do this, but I'm hoping someone very keen on algorithms has a clever way of solving the problem in an elegant solution in that the following criteria is met:
...
This came out being incomprehensible. I will rephrase
Is there an algorithm or approach that will allow sorting an array in such a way that it minimizes the differences between successive elements?
struct element
{
uint32 positions[8];
}
These records are order-insensitive.
The output file format is defined to be:
byte present; ...
This is intended to be a more concrete, easily expressable form of my earlier question.
Take a list of words from a dictionary with common letter length.
How to reorder this list tto keep as many letters as possible common between adjacent words?
Example 1:
AGNI, CIVA, DEVA, DEWA, KAMA, RAMA, SIVA, VAYU
reorders to:
AGNI, CIVA, SI...