algorithm

An interview question - Split text into sub-strings according to rules

Split text into sub-strings according to below rules: a) The length of each sub-string should less than or equal to M b) The length of sub-string should less than or equal to N (N < M) if the sub-string contains any numeric char c) The total number of sub-strings should be as small as possible I have no clue how to solve this questi...

How to find similar users using their interests

I am trying to create a system which would be able to find users with similar favourite movies/books/interests/etc., much like neighbours on last.fm. Users sharing the most mutual interests would have the highest match and would be displayed in user profiles (5 best matches or so). Is there any reasonably fast way to do this? The obviou...

John Tukey "median median" (or "resistant line") statistical test for R and linear regression

Hello guy, I'm searching the John Tukey algorithm which compute a "resistant line" or "median-median line" on my linear regression with R. A student on a mailling list explain this algorithm in these terms : "The way it's calculated is to divide the data into three groups, find the x-median and y-median values (called the s...

How exactly do you compute the Fast Fourier Transform?

Hello, I've been reading a lot about Fast Fourier Transform and am trying to understand the low-level aspect of it. Unfortunately, Google and Wikipedia are not helping much at all.. and I have like 5 different algorithm books open that aren't helping much either. I'm trying to find the FFT of something simple like a vector [1,0,0,0]. ...

Algorithm development and Security Critique: Keeping website accounts in sync with system accounts

I am writing some software in Ruby on Rails to do some simple user management for login to our server. I am working on a method for the User controller that will allow a user to change their password on the server (FTP / website login) password. I would like the administration of the server passwords to be done through the website, and...

Java solving a maze with recursion problem

I have an assignment where I am supposed to be able to display the path of a maze from the entrance to the exit and I have gotten it to work to a degree but when the maze gets more complicated with dead ends and such the program goes into infinite recursion. If you could give me any help to point me in the right direction it would be muc...

Algorithm to find the 2 largest numbers smaller than 2 integers a and b, that are divisible by each other.

So here’s the challenge. Given 2 integers named a and b: // Find the 2 largest numbers, smaller than a and b, that are divisible by each other. // input: a:102,b:53 // output: (102,51) // input: a:7,b:4 // output: (6,3) // input: a:3,b:2 // output: (2,2) The catch is, I don’t want to brute force it. I think it comes out to O(n²)....

Running time of computing mathematical functions

Where can I turn for information regarding computing times of mathematical functions? Has any (general) study with any amount of rigor been made? For instance, the computing time of constant + constant generally takes O(1). Suppose I want to start using math like integrals, and I'd like to get an asymptotic approximation to various...

Algorithm to generate outline of an alpha picture?

I'm trying to figure out an algorithm which can look at raw rgba pixels and return points that make up the polygon of the object inside example: http://img706.imageshack.us/i/polii.png// It doesn't have to return bezier curves or anything smooth or fancy, nor a connected outline as I showed, but basically the points to build such an ou...

Generating a cubic bezier curve from rough points

I'm looking for a way to make my application produce smoother results in freehand mode. Right now it simply adds each mousemove points and makes a polygon out of this. I noticed modern vector applications produce bezier curves to make it look much smoother and im wondering how this is done? So how can I get the 4 points to do bezier inte...

How can I reduce this problem to the Tower of Hanoi (or solve it in the least number of iterations)?

Suppose there are 2n+1 holes and 2 sets of n sticks, one set white and another black. The sticks are initially organized so that the white sticks are left, there is a hole in the middle and the black sticks are right. A stick can move by either: 1) being placed on the hole next to it, if empty 2) jump the neighboring stick iff the neig...

move an object follow a user-defined path on Android

What algorithm or technique should I use to make an object follow the path that the user's drawing on the screen? ...

Commandos-style Line of Sight algorithm

Hi, Could you please point me to an article on a Line of Sight RENDERING algorithm? I'm looking for something similar to the one used in the Commandos series of games (by Pyro Studios). The Line of Sight cone/triangle must be rendered (in a top down view) with appropriate shadows caused by obstructions. Thanks ...

Algorithm to cover maximal number of points with one circle of given radius

Let's imagine we have a plane with some points on it. We also have a circle of given radius. I need an algorithm that determines such position of the circle that it covers maximal possible amount of points. If there are many such positions, the algorithm should return one of them. Precision is not important and algorithm may do small mi...

Search algorithm for the smallest index in a sequence of vectors matching predefined conditions

Let us presume we have k sequences of fixed length p. Each sequence has double values in range 0 to 1.0. For simplicity let us also assume that the sequences are just arrays; in the real implementation, they will be list. Now, the algorithm needs to find the smallest index the value of which represents a "major upset" in a given sequenc...

Does Big O Measure Memory Requirments Or Just Speed?

I often here people talk about Big O which measures algorithms against each other Does this measure clock cycles or space requirements. If people want to contrast algorithms based on memory usage what measure would they use ...

Big-oh vs big-theta

Possible Duplicate: What is the difference between Θ(n) and O(n)? It seems to me like when people talk about algorithm complexity informally, they talk about big-oh. But in formal situations, I often see big-theta with the occasional big-oh thrown in. I know mathematically what the difference is between the two, but in english...

Is there an easy way to remember the rotation methods for red-black trees?

Is there an easy way to remember the rotation methods for red-black trees? ...

"Parametrized" database model & backend storage system as well as data mining manipulation

Hi Guys I have implicitly made this a community wiki seeing that the answers can be quite broad. I'm working with a start-up company to accomplish the following goal. In a medical research, a patient medical record can have infinite amount of data regarding a patient for a specific diagnosis, e.g. a smoker has a higher chance of catchi...

Generate a large random planar graph

What is the most efficient way to generate a large (~ 300k vertices) random planar graph ("random" here means uniformly distrbuted)? ...