I have a class that internally is just an array of integers. Once constructed the array never changes. I'd like to pre-compute a good hashcode so that this class can be very efficiently used as a key in a Dictionary. The length of the array is less than about 30 items, and the integers are between -1000 and 1000 in general.
...
for example if it is given to make all the choices between 1 to 5 and the answer goes like this..
1,2,3,4,5,
1-2,1-3,1-4,1-5,2-3,2-4,2-5,3-4,3-5,4-5,
1-2-3,1-2-4,1-2-5,1-3-4,
.....,
1-2-3-4-5.
can anyone suggest a fast algorithm?
...
Hi all,
I have an interesting algorithm problem here. The problem is in a way related to simulation of electronic designs.
Say for example, I have a structure containing some gates. say a 3-input AND gate.
There are 8 possible inputs i.e
000
001
...
111
Out of these 8 inputs, if I only feed in two inputs (000) and (111), I get both ...
OK - I'm almost embarrassed posting this here (and I will delete if anyone votes to close) as it seems like a basic question.
Is this the correct way to round up to a multiple of a number in C++?
I know there are other questions related to this but I am specficially interested to know what is the best way to do this in C++:
int round...
There are two algorithms presented in the web.
In both the algorithms, the first part is the same...
1. Pad the last partial plaintext block
with 0.
2. Encrypt the whole padded plaintext
using the standard CBC mode.
3. Swap the last two ciphertext blocks.
4. Truncate the ciphertext to the length of the original plaintext...
I need an algorithm or function to map each wavelength of visible range of spectrum to its equivalent RGB values.
Is there any structural relation between the RGB System and wavelength of a light?
like this image:
sorry if this was irrelevant :-]
...
I'm looking for a way to distribute a number across x units. I don't even know how to put this words so I'll give an example:
There's a tournament in which the total prize is $1000. I want that the top 20 winners/entrants will win something out of it.I need a mathematical algorithm/formula which will distibute it across those players, a...
Hi all,
I want to incorporate a full month calendar selector like that of an iOS into my program. The one like this:
However, it seem no one have come up with a control like that. Can i create a custom control like this and if yes, what is the best views to use for each date? a button view or a text view?
I would really hope someone ...
I do not know a whole lot about math, so I don't know how to begin to google what I am looking for, so I rely on the intelligence of experts to help me understand what I am after...
I am trying to find the smallest string of equations for a particular large number. For example given the number
"3940200619639447921227904010014361380507...
I got the following dictionary:
mydict = {
'foo': [1,19,2,3,24,52,2,6], # sum: 109
'bar': [50,5,9,7,66,3,2,44], # sum: 186
'another': [1,2,3,4,5,6,7,8], # sum: 36
'entry': [0,0,0,2,99,4,33,55], # sum: 193
'onemore': [21,22,23,24,25,26,27,28] # sum: 196
}
I need to efficiently filter out and...
I need to collapse multiple ranges of sequential numbers (1 or more) to sets of their minimum and maximum values. I have unique integers (no duplicates) stored in a table column.
The obvious way (to me) to solve this problem is to use a cursor (see my algorithm below) and iterate through every integer. However, it seems inefficient to ...
Do anyone know any incremental implementation of decision tree classifier. Such that it could generate optimal decision tree classifier when you add new instance to training set with low computation and as quick as possible according existing decision tree classifier?
In other words I have an optimal decision tree classifier of set A, w...
So I'm stuck with a protocol that adds a CRC8/CRC16 over odd number of bits. (ie. it's not divisible by 8) What's the best method to generate the CRC for it in software?
There are plenty of CRC algorithm that uses table, but they are lookup per byte. Of course, there's the "fail-safe" of doing it one bit at a time. But is there a be...
Possible Duplicate:
Why use a framework with PHP?
Hi, usually all the projects I do I work or with my own framework or I start them from zero. Why shouldn't I do this? or is better to keep doing it this way?
I mostly work on php, what suggestions do you have to change this? cake, joomla or another one? or just keep it this wa...
This is not homework, and I don't need to answer it, but now I have become obsessed :)
The problem is:
Design an algorithm to destructively flatten a binary tree to a linked list, breadth-first. Okay, easy enough. Just build a queue, and do what you have to.
That was the warm-up. Now, implement it with constant storage (recursion, ...
I want to generate (an image of) a single branch of a tree (the "woody plant" kind). Maybe similar to this branch, or this one.
I need it to be interesting but simple, so just one branch, with a few turns, and only a few splits (where it changes from one limb into two). It should start with one fat branch and split off into a few thin b...
Where can I find an A* implementation in C?
I was looking around but it seems my google-fu is not strong enough. I've started writing my own implementation, but then I remembered Stack Overflow and I thought I should ask here first. It seems a bit complicated to write a real A* implementation - I was tempted to just write an implementat...
Hi friends
My requirement is
1) I should construct a tree like the one which is given below in the figure.
2) I need to then compute the distance between two terms say C and D. or D and F. ( as per the figure A and B are categories C,D,E and F are terms under the respective categories.
Expected results :
Search Terms ---------- Di...
So I was writing a mergesort in C# as an exercise and although it worked, looking back at the code, there was room for improvement.
Basically, the second part of the algorithm requires a routine to merge two sorted lists.
Here is my way too long implementation that could use some refactoring:
private static List<int> MergeSortedList...
Is there another way to do this? Just spent 2 hours trying to figure it out. I have a solution (see DumpPostOrder below) however, is there is a better or more efficient method? It feels like there may be. Rules are - no recursion, and the nodes cannot have a visited flag. Ie, you can only use left + right members.
My approach was to de...