algorithm

What algorithm helps to identify repeating sequences in a DOM?

Is there a good algorithm I might apply to a DOM to lead me to groups of probably related nodes? The ultimate goal is to get something useful to assist extracting things like TOC's and "blog rolls" from websites. If something like this already exists, I'd be happy if someone let me know that as well. I realize it's not something I can h...

A problem from a programming competition... Digit Sums.

I need help solving problem N from this earlier competition: Problem N: Digit Sums Given 3 positive integers A, B and C, find how many positive integers less than or equal to A, when expressed in base B, have digits which sum to C. Input will consist of a series of lines, each containing three integers, A, B and C, 2 ...

Algorithms: Recurrence relations from CLRS

Hello All, I was recently trying to solve some recurrence relations from CLRS and I noticed a strange nuance while solving these equations. I don't know if any of you guys have noticed it or not or may be the Theory champs can throw more light on this. (I too have a degree in CS but not in Theory!). While solving the recurrence for the ...

Parallelize resolution of differential equation in Python

hi, i am solving a system of ordinary differential equations using the odeint function. Is it possible (and if yes how) to parallelize easily this kind of problem? ...

problem with listener pattern using fast enumeration

Hey, right now I have implemented my own listener pattern. I will send an update to the listeners using fast enumeration. the code will look like this - (void) updateListeners { for (id<AProtocol>listener in _listeners) { [listener update]; } and in listener, i implement method for AProtocol, which is update. suppose there are n ob...

How to detect vulnerable/personal information in CVs programmatically (by means of syntax analysis/parsing etc...)

To make matter more specific: How to detect people names (seems like simple case of named entity extraction?) How to detect addresses: my best guess - find postcode (regexes); country and town names and take some text around them. As for phones, emails - they could be probably caught by various regexes + preprocessing Don't care about...

Minimizing Sum of Distances: Optimization Problem

The actual question goes like this: McDonald's is planning to open a number of joints (say n) along a straight highway. These joints require warehouses to store their food. A warehouse can store food for any number of joints, but has to be located at one of the joints only. McD has a limited number of warehouses (say k) available, and w...

How to find number of Multiples of 3

This was a contest Q: There are N numbers a[0],a[1]..a[N - 1]. Initally all are 0. You have to perform two types of operations : Increase the numbers between indices A and B by 1. This is represented by the command "0 A B" Answer how many numbers between indices A and B are divisible by 3. This is represented by the command "1 A B"....

Tagging similar sentences with lower time complexity than n^2

Hey All This is my first post, have been a lurker for a long time, so will try my best to explain myself here. I have been using lowest common substring method along with basic word match and substring match(regexp) for clustering similar stories on the net. But the problem is its time complexity is n^2 (I compare each title to all the...

Algorithm for stacking events/items

I'm looking to build a pseudo Gantt chart, except one where events can be on the same line as long as they don't overlap, something like this: M T W R F S U M T W R F S U M T W R F S U Category 1: |Event 1| |Event 2| |------Event 3--| |---------Event 4-----------| |-Event 5-| I'm looking for an alg...

Algorithm to produce Cartesian product of arrays in depth-first order

I'm looking for an example of how, in Ruby, a C like language, or pseudo code, to create the Cartesian product of a variable number of arrays of integers, each of differing length, and step through the results in a particular order: So given, [1,2,3],[1,2,3],[1,2,3]: [1, 1, 1] [2, 1, 1] [1, 2, 1] [1, 1, 2] [2, 2, 1] [1, 2, 2] [2, 1, 2]...

1D path finding with 'teleporters'

Problem I want ot write a simple 1D RTS game and have the following path finding problem: There are many one-dimensional lines and everywhere are teleporters which can be used to travel between the lines but also to travel inside the current line. The teleporters are the only way to travle between lines. What algorithm or pseudo code ca...

Efficient insertion/deletion algorithm for an array

Hi there, I subscribe to a data feed and from that create and maintain a structure using the index values on the INSERT/DELETE messages. I would like to ask the assembled cognoscenti whether they know of any algorithm which can deal with the piecemeal updates in an efficient way - generally batch-updates contain between two and six suc...

vector space model algorithm in Java to get the similarity score between two people

Hello all, I am trying to use/implement a vector space model algorithm in Java to get the similarity score between two people based on its keywords. So I have the following classes: Person - Has a List of keywords; Keyword - String text; Integer score; The keyword score is the number of mentions the person has made to the keyword. ...

The most efficient way to remove all characters in the 1st string from the 2nd string?

I was asked about this question. I can only think of a O(nm) algorithm if n is the length of the 1st string and m is the length of the 2nd string. ...

How to sort an array using minimum number of writes?

My friend was asked a question in his interview: The interviewer gave him an array of unsorted numbers and asked him to sort. The restriction is that the number of writes should be minimized while there is no limitation on the number of reads. ...

dynamically add different strings into an array list base on a pattern/algorithm/formula

is there a way to dynamically add this whole adding process instead of the manually entering the values like a.Add("1 & 2"); and so on by the way, this only happens if i select 5 conditions -i am doing the adding base on the maximum condition i cater which is 5 the subsets that i show below must be in that pattern although its ok that ...

Order of growth

for f = n(log(n))^5 g = n^1.01 is f = O(g) f = 0(g) f = Omega(g)? I tried dividing both by n and i got f = log(n)^5 g = n^0.01 But I am still clueless to which one grows faster. Can someone help me with this and explain the reasoning to the answer? I really want to know how (without calculator) one can determine which one grow...

bitmap interpolation

interpolation of bitmap: I have bitmap of 16*16, i want to increase the size of the bitmap to 160*160, which is best interpolation type that can be suited. ...

Finding the optimum file size combination

Hello, This is a problem I would think there is an algorithm for already - but I do not know the right words to use with google it seems :). The problem: I would like to make a little program with which I would select a directory containing any files (but for my purpose media files, audio and video). After that I would like to enter in...