algorithm

What is the fastest factorization algorithm?

I've written a program that attempts to find Amicable Pairs. This requires finding the sums of the proper divisors of numbers. Here is my current sumOfDivisors() method: int sumOfDivisors(int n) { int sum = 1; int bound = (int) sqrt(n); for(int i = 2; i <= 1 + bound; i++) { if (n % i == 0) sum = s...

Compression of numeric strings

Can anyone suggest compression algorithms to operate on numeric strings of 20-30 digits ? ...

Algorithm to choose random letters for word search game that allows many words to be spelled

I'm making a boggle-like word game. The user is given a grid of letters like this: O V Z W X S T A C K Y R F L Q The user picks out a word using any adjacent chains of letters, like the word "STACK" across the middle line. The letters used are then replaced by the machine e.g. (new letters in lowercase): O V Z W X z e x o p Y R F L Q...

Moving between co-ordinates, Java Algorithms

Ok this question is going to be a little abstract. I have an icon moving along a line which is represented by a series of coordinates stored in a vector, and I am iterating through them. The distance between coordinates is variable. So sometimes the icon will move slowly and smoothly, and others it will jump several 100 pixels at a time...

What's a nice method to factor gaussian integers?

I already have prime factorization (for integers), but now I want to implement it for gaussian integers but how should I do it? thanks! ...

Algorithm needed for solving building-blocks problem.

Consider the following scenario: We have a number of sequential building blocks (e.g. 12 building blocks, ordered from 1 to 12), distributed randomly (but not necessarily equally) on a number of builders (e.g. 3 builders). The builders are required to work in order and start building the wall from block number 4, both ways; down to blo...

Calculating number of messages per second in a rolling window?

I have messages coming into my program with millisecond resolution (anywhere from zero to a couple hundred messages a millisecond). I'd like to do some analysis. Specifically, I want to maintain multiple rolling windows of the message counts, updated as messages come in. For example, # of messages in last second # of messages in last ...

Any free copy of "Introduction to Algorithms: A Creative Approach" to read it online?

Hello, I've been waiting for a long time to read "Introduction to Algorithms: A Creative Approach" Written by Udi Manber. Published by Addison-Wesley. The book is not available in print in the place I live. I was wondering if is there any free copy available to read it online. Please do not suggest, buying it online. I seriously canno...

Would like help thinking algorithmically about server-side video encoding.

I've been learning PHP and MySQL and have been thinking about exercises to help me learn the language better. I've used ffmpeg for a few years now to process video files and thought I could probably work out a way to manage this from the web. I've read up on using ffmpeg from php but I'm wondering how to manage the files on the backend. ...

Convergence of BFGS for convex over-parameterized problems

It is "well-known" that the BFGS optimization algorithm is superlinearly convergent for strictly convex problems, but is there any analysis for problems that are non-strictly convex. For example, suppose that f(x) is convex for some scalar x. Then, suppose we optimize over g(x1,x2)=f(x1+x2). Will this still always be superlinearly con...

Using webcam to track hand gestures

I wanted to develop a program which uses the webcam to track four colours and which are going to be on my index finger and thumb of both my hands and according to the gestures of my hand the computer will interpret these gestures and carry out a command. For example if I have a website open, all I have to do is pinch with my fingers and ...

Grouping related search keywords

I have a log file containing search queries entered into my site's search engine. I'd like to "group" related search queries together for a report. I'm using Python for most of my webapp - so the solution can either be Python based or I can load the strings into Postgres if it is easier to do this with SQL. Example data: dog food goo...

Efficient algorithm for finding spheres farthest apart in large collection

I've got a collection of 10000 - 100000 spheres, and I need to find the ones farthest apart. One simple way to do this is to simply compare all the spheres to each other and store the biggest distance, but this feels like a real resource hog of an algorithm. The Spheres are stored in the following way: Sphere (float x, float y, float...

Way to store a large dictionary with low memory footprint + fast lookups (on Android)

I'm developing an android word game app that needs a large (~250,000 word dictionary) available. I need: reasonably fast look ups e.g. constant time preferable, need to do maybe 200 lookups a second on occasion to solve a word puzzle and maybe 20 lookups within 0.2 second more often to check words the user just spelled. EDIT: Lookups...

How to determine whether a string is composed only of letters given by a second string.

I have two strings. How can I determine whether the first string is composed only of letters given by the second string? For example: A = abcd B = abbcc should return false, since d is not in the second string. A = aab B = ab should return true. If the program most of the time returns false, how can I optimize this program? If i...

Calculate the sum of elements in a matrix efficiently

In an interview I was asked if I was given an n*m matrix how to calculate the sum of the values in a given sub-matrix (defined by top-left, bottom-right coordinates). I was told I could pre-process the matrix. I was told the matrix could be massive and so could the sub-matrix so the algo had to be efficient. I stumbled a bit and was...

Python UUID represented as special characters

When creating a UUID in Python, likeso: >>> uuid.uuid1() UUID('a8098c1a-f86e-11da-bd1a-00112444be1e') How could one map that UUID into a string made up of the capitalized alphabet A-Z minus the characters D, F, I, O, Q, and U, plus the numerical digits, plus the characters "+" and "=". i.e. the from an integer or string onto the set o...

Algorithm to computer the optimal layout of n-ary tree?

I am looking for an algorithm that will automatically arrange all the nodes in an n-tree so that no nodes overlap, and not too much space is wasted. The user will be able to add nodes at runtime and the tree must auto arrange itself. Also note it is possible that the tree's could get fairly large ( a few thousand nodes ). The algorithm ...

Algorithm for building tree hierarchy based on URL paths

This is related to http://stackoverflow.com/questions/711793/parse-url-strings-into-tree-hierarchy But i'm implementing in javascript, therefore require some algorithm here instead of using SQL functions. ...

Why should I learn algorithms?

Hi all, This is my first qestion in the forum. I am a student of Software Engineering. Today I asked this question to my teacher in class. But did not get any satisfactory answer Can any one please give me some insight why should i learn this topic in my graduations. ...