Hi,
I have a set K of randomly selected pixels in a 2D image. For every other pixel in the image I need to find out which pixel in set K is closest to it (using the standard sqrt(dx^2 + dy^2) measure of distance). I am aware that there may be more than one solution for each pixel. Obviously it can be done by brute force against every pi...
Hi, I'm looking for a nice and efficient implementation of Xiaolin Wu's anti-aliased line drawing algorithm in C, does anyone have this code they could share with me?
Thanks
...
For performance reasons I have a need to split a set of objects identified by a string into groups. Objects may be either identified by a number or by a string in prefixed (qualified) form with dots separating parts of the identifier:
12
323
12343
2345233
123123131
ns1:my.label.one
ns1:my.label.two
ns1:my.label.three
ns1:system.text.one...
I'm using the Allegro game library to make a tile game. I want the tiles to get exponentially brighter. Unfortunately Allegro does not have a "Brighten" feature. What I then decided to do, was blit a tile to the buffer, then for each pixel that it just blited for that tile, I increased their rgb values and putpixel. The big problem with ...
KMP is for searching,what's the one for replacing?
...
Hi,
I have been struggling with this questions for sometime now. The question goes like this:-
We have n^2 numbers. We need to find out if there exists a triplet a,b,c such that a+b+c = 0. For a more generic case, a+b+c = k. (k is given)
There exists a solution with O(n^2log(n)) complexity.
Any help would be greatly appreciated.
th...
I am writing a document and was unsure of the following:
I am going to compare two algorithms that can perform on the same structure but we cant say one will always be faster than the other (and I will define circumstances in which a is better than b and vice versa); for this I was going to use quicksort and bubblesort. Is this a good ...
G'day all,
I tried the solution for eight puzzle problem posted here
by joel Neely and played around with it and modified it so that can be used to solve for higher grids[Changed the String representation of the grid to two dimensional integer representation and modified
the logic accordingly]. However the modified code can solve th...
Given two arrays hashes and table, for each value in hashes I want to store the position of the element at the element's value's offset in the array table. Here is the naïve algorithm:
def insert_n(table,hashes):
for x in xrange(len(hashes)):
table[hashes[x]]=x
This is extremely slow. Psyco helps some here, but hardly.
N...
I am comparing two algorithms, Prim's and Kruskal's.
I understand the basic concept of time complexity and when the two work best (sparse/dense graphs)
I found this on the Internet, but I am struggling to convert it to English.
dense graph: Prim = O(N2)
Kruskal = O(N2*log(N))
sparse graph: Prim = O(N2)
Kr...
Dijkstra's is typically used to find the shortest distance between two nodes in a graph. Can it be used to find a minimum spanning tree? If so, how?
Edit: This isn't homework, but I am trying to understand a question on an old practice exam.
...
EDIT: I've got it, thanks for all the help everyone! + Cleaned up post a little bit.
Also, this article was very helpful: http://www.codinghorror.com/blog/archives/001204.html?r=1183
Hi all,
I've been asked (as part of homework) to design a Java program that does the following:
Basically there are 3 cards:
Black coloured on bot...
I have a data structure as the image below illustrates. I need to quickly figure out the index of the cells to the right or left of the highlighted cell group.
You can see in the code below I am naively looping through ALL cells at every index to determine if there is a cell at the requested index. This works great when I have a few (...
I have a list of 300000 lists (fiber tracks), where each track is a list of (x,y,z) tuples/coordinates:
tracks=
[[(1,2,3),(3,2,4),...]
[(4,2,1),(5,7,3),...]
...
]
I also have a group of masks, where each mask is defined as a list of (x,y,z) tuples/coordinates:
mask_coords_list=
[[(1,2,3),(8,13,4),...]
[(6,2,2),(5,7,3),...]
...
]...
I have some tests that use guids. The guids used don't need to be enormously unique, they just need to be guids. Random guids are boring - so I'm trying to find fun guid words. Right now, I don't have anything better than "00000000-feed-dada-iced-c0ffee000000". Ideally I'd generate a list of verbs, nouns, prepositions.
Having only spent...
Given a problem, how to come up with a recurrence equation?
For example :
Let S be a set of n>0 distinct integers. Assume that n is a power of 3.
A ternary comparison can compare three numbers from the set S and
order them from the largest to the smallest.
Describe an efficient algorithm that uses as few as possible ternary compariso...
public static class Global
{
public static List <Faction> Factions;
public static Dictionary <Faction, FactionRelation> FactionRelationships;
}
public class Faction
{
public Faction Parent;
}
public class FactionRelation
{
public Faction ForeignFaction; //The enemy or friend of this faction
public decimal Multip...
I have been searching everywhere, including the Stack Overflow archives, for an answer of how to do this, I tried rolling my own, but have come up short, so I decided I would post my request here.
I need to take an arbitrary (even) number of items in an array and return with item paired with another item in the array. I need the output ...
First and foremost, no I'm not asking please tell me how Google is built in two sentences. What I am asking is slightly different. I have a database filled with textual data that users input. We also give them the functionality to search for this data later. The problem is, we do a simple full text search now and return the results in an...
I'm making a game in c++ and it involves filling tiles with random booleans (either yes or no) whether it is yes or no is decided by rand() % 1. It doesnt feel very random. I'm using srand with ctime at startup, but it seems like the same patterns are coming up. Are there any algorithms that will create very random numbers? Or any sugges...