algorithm

Algorithm to find common substring across N strings

I'm familiar with LCS algorithms for 2 strings. Looking for suggestions for finding common substrings in 2..N strings. There may be multiple common substrings in each pair. There can be different common substrings in subsets of the strings. strings: (ABCDEFGHIJKL) (DEF) (ABCDEF) (BIJKL) (FGH) common strings: 1/2 (DEF) 1/3 (ABCDEF) 1/4...

Compression algorithms specifically optimized for HTML content?

Are there any compression algorithms -- lossy or lossless -- that have been specifically adapted to deal with real-world (messy and invalid) HTML content? If not, what characteristics of HTML could we take advantage of to create such an algorithm? What are the potential performance gains? Also, I'm not asking the question to serve such...

How can I compute a Cartesian product iteratively?

This question asks how to compute the Cartesian product of a given number of vectors. Since the number of vectors is known in advance and rather small, the solution is easily obtained with nested for loops. Now suppose that you are given, in your language of choice, a vector of vectors (or list of lists, or set of sets, etc.): l = [ [1...

Where to find free tutorials about trading algorithms

Hi I would like to find some tutorial about the trading algorithms like Iceberg, Dagger, Guerrilla etc. I have just found some non-free or marketing sites on this topic. ...

Finding cells in a grid with varying grid cell sizes

I have a grid of rectangular cells covering a plane sitting at some distance from the coordinate system origin and would like to identify the grid cell where a straight line starting at the origin would intersect it. The cells on the grid have equal sizes (dx,dy) and there are no gaps between cells, but since every cell on the plane has...

Algorithm for computing the inverse of a polynomial

I'm looking for an algorithm (or code) to help me compute the inverse a polynomial, I need it for implementing NTRUEncrypt. An algorithm that is easily understandable is what I prefer, there are pseudo-codes for doing this, but they are confusing and difficult to implement, furthermore I can not really understand the procedure from pseud...

Finding all shortest paths from every pair of nodes on a graph

I have about 70k nodes, and 250k edges, and the graph isn't necessarily connected. Obviously using an efficient algorithm is crucial. What do you recommend? As a side note, I would appreciate advice on how to divide the task up between several machines--is that even possible with this kind of problem? Thanks ...

How can I store this kind of graph in neo4j for fast traversal?

This is a graph whose nodes exist in many connected components at once because a node's relationships are a collection of edge groups such that only one edge per edge group can be present at once. I need to be able to find all of the connected components that a node exists in. What would be the best way to store this graph in neo4j to qu...

SML travelling salesman problem

please anybody having travelling salesman problem solution in Standard ML, plz tell me. I've tried a lot but am not successfull... Thx in advance. ...

Scheduling Students to Classes

I am making a website for a side project at school where students enter the classes they need to take, what days they want or don't want classes, and when they cant have or don't want classes. The basics are there are classes, and each class has many sections at different times with different professors that a student can choose from. Wi...

Need to devise a number crunching algorithm

I stumbled upon this question: 7 power 7 is 823543. Which higher power of 7 ends with 823543 ? How should I go about it ? The one I came up with is very slow, it keeps on multiplying by 7 and checks last 6 digits of the result for a match. I tried with Lou's code: int x=1; for (int i=3;i<=100000000;i=i+4){ x=(x*7)...

Merging elements in a scala list

I'm trying to port the following Java snippet to Scala. It takes a list of MyColor objects and merges all of the ones that are within a delta of each other. It seems like a problem that could be solved elegantly using some of Scala's functional bits. Any tips? List<MyColor> mergedColors = ...; MyColor lastColor = null; for(Color aColor ...

Can I use a plaintext diff algorithm for tracking XML changes?

Hi all! Interesting question for you here. I'm working in Flex/AS3 on (for simplicity) an XML editor. I need to provide undo/redo functionality. Of course, one solution is to store the entire source text with each edit. However, to conserve memory, I'd like to store the diffs instead (these diffs will also be used to transmit update...

Graph diffing and versioning tool

I am working with a team that edits large DAGs represented as single files. Currently we are unable to work with multiple users concurrently modifying the DAG. Is there a tool (somewhat like the Eclipse SVN plugin) that can do do revision control on the file (manage timestamps/revision stamps) to identify incoming/outgoing/conflicting c...

Word Counter Implementation

Is there a better way than the following brute foce implementation of a c# word counting class? UPDATED CODE: Sorry! /// <summary> /// A word counting class. /// </summary> public class WordCounter { Dictionary<string, int> dictTest = new Dictionary<string, int> (); /// <summary> /// Enters a word and returns the current n...

coverage of xml document with variables and paths

For coverage, I've a set of run time variables of from my program execution. It happens that I get it from a series of executions(Automated testing). ie. its a vector<vector<var,value>> I've a limited set of variables with expected values and generate combination s, that is I have vector<vector<var,value>(smaller than the execution vect...

computing "node closure" of graph with removal

Given a directed graph, the goal is to combine the node with the nodes it is pointing to and come up with minimum number of these [lets give the name] super nodes. The catch is once you combine the nodes you can't use those nodes again. [first node as well as all the combined nodes - that is all the members of one super node] The gr...

Is there any algorithm for calculating area of a shape given co-ordinates that define the shape ?

So I have some function that receives N random 2D points. Is there any algorithm to calculate area of the shape defined by the input points? ...

Test if a number is fibonacci

I know how to make the list of the Fibonacci numbers, but i don't know how can i test if a given number belongs to the fibonacci list - one way that comes in mind is generate the list of fib. numbers up to that number and see if it belongs to the array, but there's got to be another, simpler and faster method. Any ideas ? ...

Given a decimal number, find the smallest integer multiplier that gives an integer result

Best to use an example to describe the problem. Lets say I have a decimal value 100.227273. 100.227273 * X = Y I need to find the smallest positive integer X that gives integer Y. ...