I have an application that is on a mobile device. I am moving resolutions of my app from 240W x 320L to 640W X 480L.
I have a bunch of columns that have their width in pixels (say 55 for example). I need to convert this to the new resolution.
"Easy", I thought 640/240 = 2 2/3. So I just take 55 * 2.6666667 and that is my new width. ...
Hello All,
I need to generate all permutation of a string with selecting some of the elements. Like if my string is "abc" output would be { a,b,c,ab,ba,ac,ca,bc,cb,abc,acb,bac,bca,cab,cba }.
I thought a basic algorithm in which I generate all possible combination of "abc" which are {a,b,c,ab,ac,bc,abc} and then permute all of them.
S...
I want to store pointers to one instance of an object in some (two or more) containers. I've met one problem in this idea: how I can handle removing of this object. Objects have rather stormy life (I am talking about game, but I think this situation is not so specific) and can be removed rather often. To my mind this problem is divided i...
I have a range in java implemented as a class which is divided into sub-ranges. The implementation is roughly as follows:
public class Range
{
static public class Key implements Comparable<Key>
{
public int start;
public int end;
...
}
Key range;
SortedMap<Key, Range> subRange;
}
I want to make a func...
Given image is N*M (R,G,B) pixels like:
Algorithm should tall us how to find main image colors like: red and white here.
Aeries with relatively same colors means we search for (R,G,B) (222, 12, 10) giving for example such step (40, 20, 10 ) so that (199, 32, 5) will count like what we are searching for like:
Shapes should be de...
Hi all:
i am reviewing my data structures and algorithm analysis lesson,and i get a question that how to determine to the space complexity of merge sort and quick sort
algorithms ?
The depth of recursion is only O(lgn) for linked list merge-sort
The amount of extra storage space needed for contiguous quick sort is O(n).
My th...
Overview
I'm looking to analyse the difference between two characters as part of a password strength checking process.
I'll explain what I'm trying to achieve and why and would like to know if what I'm looking to do is formally defined and whether there are any recommended algorithms for achieving this.
What I'm looking to do
Across ...
I am playing around with implementing a junction tree algorithm for belief propagation on a Bayesian Network. I'm struggling a bit with triangulating the graph so the junction trees can be formed.
I understand that finding the optimal triangulation is NP-complete, but can you point me to a general purpose algorithm that results in a 'g...
Let's say I have an unsorted list of four objects: [B, C, A, D].
All four objects are of the same type, and:
(A > B),
(C > D),
(A != C or D)
(B != C or D)
(C != A or B)
(D != A or B).
By "!=", I mean that they are neither less-than, equal-to, or greater-than the other objects.
I need to "sort" the list such that A will alway...
I'm trying to come up with a reasonable algorithm for this problem:
Let's say you have a bunch of balls. Each ball has at least one color, but can also be multicolored. Each ball also has a number on it. There are also a bunch of boxes which are each only one color. The goal is to maximize the sum of the numbers on the balls in the ...
Anyone know the facemash algorithm that Mark Zuckerberg implemented in his facemash site?
http://www.thecrimson.com/article/2003/11/19/facemash-creator-survives-ad-board-the/
Preferably in PHP & MySQL.
Thanks!
Matt
...
Based on this original idea, that many of you have probably seen before:
http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/
I wanted to try taking a different approach:
You have a target image. Let's say you can add one triangle at a time. There exists some triangle (or triangles in case of a tie) that maxi...
I have some data like this:
1 2
3 4
5 9
2 6
3 7
and am looking for an output like this (group-id and the members of that group):
1: 1 2 6
2: 3 4 7
3: 5 9
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to me like a graph traversal but the f...
Let's say I'm playing 10 different games. For each game, I know the probability of winning, the probability of tying, and the probability of losing (each game has different probabilities).
From these values, I can calculate the probability of winning X games, the probability of losing X games, and the probability of tying X games (for ...
Hey there, this is my first post so please don't be too hard on me.
I wrote an "insert" function to insert an integer into an array of integers. It works, but I don't know if it's the best algorithm.
Here's my code:
int* insert(int *dest, size_t len, unsigned int index, int value)
{
int x = 0, i = 0;
int *stackp = calloc(len+1, sizeof...
Can anyone explain how to improve the quicksort algorithm for finding the median of n odd numbers and what will be the worst case scenario for that algorithm? Please help.
...
What is the fastest way to calculate the n-th root of a number?
I'm aware of the Try and Fail way, but I need a faster algorithm.
...
Hello SO,
I am playing with computer graphics programming for the first time.
Don't ask me why, but it feels like a good day to convert RGB (24bit) images, to indexed-palette (8bit) images (like GIF).
How would one go about picking the optimal palette, for a given image?
I just thought of going with k-means, with k=256.
Any suggestions, ...
Trying to imitate Excel's SUMPRODUCT function:
SUMPRODUCT(v1, v2, ..., vN) =
v1[0]*v2[0]*...*vN[0] + v1[1]*v2[1]*...*vN[1] + ... + v1[n]*v2[n]*...*vN[n]
where n is the number of elements in each vector.
This is similar to dot product, but for multiple vectors. I read the very detailed discussion of the regular dot product, but I ...
Hi,
The question was difficult to phrase. Hopefully this will make sense.
I have a table of items in my INVENTORY.
Let's call the items Apple, Orange, Pear, Potato. I want to pick a basket of FRUIT (1 x Apple,1 x Orange, 1 x Pear).
Each item in the INVENTORY has a different date for availability. So that...
Apple JANUARY
Apple FEB...