I did recently attach the 3rd version of Dijkstra algorithm for shortest path of single source into my project.
I realize that there are many different implementations which vary strongly in performance and also do vary in the quality of result in large graphs. With my data set (> 100.000 vertices) the runtime varies from 20 minutes to...
This question is similar to my last question. Except this time I'm using letters rather than 6 digit integers. I want to find the out of sequence "letters".
Let's say I have the following data:
id | Date | Letter
-----------------------------
01 | 5/1/2009 | X
02 | 5/1/2009 | Y
03 | 5/1/2009 | Z
04 | 5/1/2009 | A
05 | 5/1/2009 | B
06 ...
I have a list of points. Each point being an x and y coordinate (both of which are integers). Now I'm trying to find known patterns, such as lines, arcs or circles, knowing that the points are not perfectly on the pattern.
What's the best way to do it? I don't have many clues to get started.
Edit: the points are ordered. The user is dr...
Hi,
I am looking for an efficient way to represent and retrieve the geographical relationship eg. districts->states->USA. This should accommodate any level of hierarchy eg. district->region->states->big region(East/west/south/north) -> USA.
My requirements are
I mostly operate at the lowest level - so getting all of them fast should...
I'm looking to change the speed of a sound file, but am at a loss as to how to accomplish it. I'm assuming that some type of interpolation has to take place in the case of slowing it down, but am unsure how to accomplish a speed up - perhaps an average of several samples? Whether it changes the tempo or pitch doesn't really matter at t...
I am writing a utility that reflects on two object graphs and returns a value to indicate whether the graphs are identical or not. It got me thinking, is there a generally accepted pattern for writing a recursion algorithm that returns a value from some where in the recursion?
My solution would probably use a ref parameter and look som...
Let's say I have the following table in SQL Server 2005:
id | Date | Letter
-----------------------------
01 | 5/1/2009 | W
02 | 5/1/2009 | X
03 | 5/1/2009 | Y
04 | 5/1/2009 | Z
05 | 5/1/2009 | A
06 | 5/1/2009 | B
07 | 5/1/2009 | D
08 | 5/1/2009 | E
09 | 5/2/2009 | W
10 | 5/2/2009 | X
11 | 5/2/2009 | Y
12 | 5/2/2009 | Z
13 | 5/2/2009 | ...
What are some examples where Big-O notation[1] fails in practice?
That is to say: when will the Big-O running time of algorithms predict algorithm A to be faster than algorithm B, yet in practice algorithm B is faster when you run it?
Slightly broader: when do theoretical predictions about algorithm performance mismatch observed runnin...
What is QuickSort with a 3-way partition?
...
Hi,
I'm a newbie to Haskell, and I'm trying to write an elegant function to merge an arbitrary number of sorted lists into a single sorted list... Can anyone provide an elegant and efficient reference implementation?
Thanks!
...
hi,
after a hard work, my brain turns out of service.. (it is 11:40 P.M. in Turkey)
i am doing a rotation job like that:
variables:
_cx = horizontal center of rect
_cy = vertical center of rect
_cos = cos value of current angle
_sin = sin value of current angle
to rotating any point in this rect :
function getx(x, y)
{
retur...
Given a list of words, how would you go about arranging them into a crossword grid?
It wouldn't have to be like a "proper" crossword puzzle which is symmetrical or anything like that: basically just output a starting position and direction for each word.
...
I want to implement the two above mentioned image resampling algorithms (bicubic and Lanczos) in C++. I know that there are dozens of existing implementations out there, but I still want to make my own. I want to make it partly because I want to understand how they work, and partly because I want to give them some capabilities not found ...
A few days ago, you helped me to find out an algorithm for generating random strength values in an online game (thx especially John Rasch).
function getRandomStrength($quality) {
$rand = mt_rand()/mt_getrandmax();
$value = round(pow(M_E, ($rand - 1.033) / -0.45), 1);
return $value;
}
This function generates values between ...
I have an algorithm for knight's tours on chessboards of various sizes (large sizes, like 100x100) and I'd like to animate the result. Each time the knight moves to a new square, a corresponding pixel in the (square) canvas will change colours, until eventually the whole canvas is coloured in. The resulting movies will be available for v...
Does anyone know an efficient algorithm to compute a line digraph from a digraph? See http://en.wikipedia.org/wiki/Line_graph (The Wikipedia article mentions the digraph case near the bottom (in the Generalizations sections). Ideally I would like to do this in linear time.
From that section:
If G is a directed graph, its directed ...
Which models of algorithm running time exist?
We all expect mergesort to be faster than bublesort, and note that mergesort makes O(n log n) comparisons vs. O(n2) for bubblesort.
For other algorithms, you count other operations (than compares and swaps), such as pointer dereference, array lookup, arithmetic on fixed-size integers, etc.
...
I've got a text file that looks like this:
{ Id = 1, ParentId = 0, Position = 0, Title = "root" }
{ Id = 2, ParentId = 1, Position = 0, Title = "child 1" }
{ Id = 3, ParentId = 1, Position = 1, Title = "child 2" }
{ Id = 4, ParentId = 1, Position = 2, Title = "child 3" }
{ Id = 5, ParentId = 4, Position = 0, Title = "grandchild 1" }
I...
What is an efficient way to generate a random contingency table? A contingency table is defined as a rectangular matrix such that the sum of each row is fixed, and the sum of each column is fixed, but the individual elements may be anything as long as the sum of each row and column is correct.
Note that it's very easy to generate rando...
Calculating the k-core of a graph by iteratively pruning vertices is easy enough. However, for my application, I'd like to be able to add vertices to the starting graph and get the updated core without having to recompute the entire k-core from scratch. Is there a reliable algorithm that can take advantage of the work done on previous it...