algorithm

grouping strings by similarity

I have an array of strings, not many (maybe a few hundreds) but often long (a few hundred chars). Those string are, generally, nonsense and different one from the other.. but in a group of those string, maybe 5 out of 300, there's a great similarity. In fact they are the same string, what differs is formatting, punctuation and a few wor...

How do I generate a uniform random integer partition?

A Google search reveals plenty about generating all possible partitions of an integer n into m parts, but I haven't found anything about sampling a uniformly distributed random partition of n into m parts. ...

Algorithm for rdbms, select statement

hello dunno if this is the correct place to ask for this question,, im havin a thesis research and im in the algoritm now.. my thesis is an application that send messages using wherein the contacts will be query from the db.. so my question is what is the algorithm for searching the contacts from DB? linear search?? ...

Syntax discovery, or, sentence tree builder...

Hi, I'm usually pretty adept with algorithms, but I've got a pretty abstract question here, which is probably someone's PhD project somewhere, and bordering on NP completeness. But maybe it's a more common problem than I think. I have a list of 25000 Strings, created using a bunch of drop down lists and text fields. So, to simplify...

How to find the center of gravity or center of mass of an irregular body with uniform mass distribution?

Hi, Recently I was trying to solve a small AI problem but got stuck in between as I could not find the center of mass of the various bodies. I was wondering if any one of you could help me out with this one. Problem explanation: Assume that i have a 2D body which is very irregular in shape and has a uniform mass distribution throughout....

How do I go about building a matching algorithm?

I've never built an algorithm for matching before and don't really know where to start. So here is my basic set up and why I'm doing it. Feel free to correct me if I'm not asking the right questions. I have a database of names and unique identifiers for people. Several generated identifiers (internally generated and some third party), ...

Divide a list of numbers into smaller list with "sum" approximately same.

I execute around 2000 tests on grid, each test being run as separate task on grid. The tests do have rather big startup time. Total execution takes 500 hours, finishes in less than 10 hours on 60 node SunGridEngine. Runtime of tests vary from 5 minutes to 90 minutes. Combining tests without much intelligence gave some performance gain....

Algorithm for searching for an image in another image. (Collage)

Is this even possible? I have one huge image, 80mb with a lot of tiny pictures. They are tilted and turned around as well. How can i search for an image with programming? I know how to use java and c++. How would you go about this? ...

Tips For Dealing With Huge RAM Working Sets

I am working on a .Net 3.5 application designed specifically for a high-powered PC that does lots of data manipulation and computation. I recently encountered a need for a 4000 x 5000 two-dimensional array of objects, which is very large for a 32-bit PC and will give me an OutOfMemoryException. The only way to avoid using an array like t...

What algorithm to use to segment a sequence of numbers into n subsets, to minimize the standard deviation of the sum of the numbers in each subset

I'm looking for an algorithm to segment a sequence of positive numbers into n subsequences, such that the standard deviation of the sum of the numbers in each subset is minimized. The ordering of the numbers in each subsequence needs to be the same as the ordering in the original sequence For example: Suppose I have a sequence {1,1,...

How to calculate that has passed six months from a given date in VB6?

This is not an homework question :). I would like to code a function that return True if 6 months has passed since a given date (so, i'm on the first day of the seventh month). Function PassedSixMonthsSince(Dim dGivenDate as Date, Dim dCurrentDate as Date) as Boolean These are some tests that this function must pass: Debug.As...

strongly connected components(SCC graph algorithm) in SML

Hi I need to write SCC algorithm in standard ML. but I don't know how to do that. I have following TYPEs whitch has to be uesd in code: type vertex = int type edge = int * int type graph = (vertex * vertex list) list fun dfs (g: graph) (n: vertex): vertex list = let fun helper (todo: vertex list) (visited: vertex list): vertex ...

Find integer not occurring twice in an array.

I am trying to solve this problem: In an integer array all numbers occur exactly twice, except for a single number which occurs exactly once. A simple solution is to sort the array and then test for non repetition. But I am looking for better solution that has time complexity of O(n). ...

How to sort a stack using only Push, Pop, Top, IsEmpty, IsFull?

Given a stack S, need to sort the stack using only Push, Pop, Top, IsEmpty, IsFull. Looking for most simple solution. Edited: Removed in place condition. Can't use another stack or queue. ...

Where to find algorithms for standard math functions?

I'm looking to submit a patch to the D programming language standard library that will allow much of std.math to be evaluated at compile time using the compile-time function evaluation facilities of the language. Compile-time function evaluation has several limitations, the most important ones being: You can't use assembly language. Y...

iPhone -- possible to tell the difference between a fingertip and a whole fingerpad?

Is it possible to detect exactly how much finger is in contact with the screen? Say I wanted to make a fingerprinting app, how would I detect the outline of a person's fingeR? ...

anyone know how to decode huffman tree?

is there better way than just go left or right based on the input digit 0 or 1? ...

An efficient way that deletes specified characters from a string

For example, given a str of "Stackoverflow is for every one" and remove of "aeiou", the function should transform str to "Stckvrflw s fr vry n". I have one char array of string: str[] and one char array of chars to be removed:remove[] My Solution: Loop str[] looking for each in character in remove[]. Shift str[] one place left every-t...

Intersection of two linked lists

Given two sorted linked lists, L1 and L2, a solution to compute their intersection L1 intersection L2. ...

Implementing a mergesort without using an additional array?

I've read a lot about mergesort recently and I wonder if there is a way to do a mergesort without using at least one additional array. Is it possible? ...