algorithm

How can a transform a polynomial to another coordinate system?

Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n' Ax^(n-1) + Bx^(n-2) + ... + Z I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomial curve. Now here's the catch. I've done this work in one coordinate system we'll call "data sp...

Bron-Kerbosch algorithm for clique finding

Can anyone tell me, where on the web I can find an explanation for Bron-Kerbosch algorithm for clique finding or explain here how it works? I know it was published in "Algorithm 457: finding all cliques of an undirected graph" book, but I can't find free source that will describe the algorithm. I don't need a source code for the algori...

Where can I find open source 2d bin packing algorithms?

I'm looking for open source (preferably c++) algorithms for 2d bin packing of rectangular and or irregular shapes. I've found several papers on the subject but no code. ...

What is search.twitter.com's "trending topics" algorithm?

What algorithm does twitter use to determine the 10 topics that you can see at search.twitter.com? I would like to implement that algorithm and I would also like to show the 50 most popular topics (instead of 10). Can you describe the most efficient algorithm? Thanks! (Twitters API can be found at- http://apiwiki.twitter.com/REST%20API...

Algorithm to estimate number of English translation words from Japanese source

I'm trying to come up with a way to estimate the number of English words a translation from Japanese will turn into. Japanese has three main scripts -- Kanji, Hiragana, and Katakana -- and each has a different average character-to-word ratio (Kanji being the lowest, Katakana the highest). Examples: computer: コンピュータ (Katakana - 6 chara...

How to find out which numbers occur the most in a given group of numbers?

Suppose we have a vector/array in C++ and we wish to count which of these N elements has maximum repetitive occurrences and output the highest count. Which algorithm is best suited for this job. example: int a = { 2, 456, 34, 3456, 2, 435, 2, 456, 2} the output is 4 because 2 occurs 4 times. That is the maximum number of times 2 occu...

Near Sorting Algorithms - When to use?

From time to time I browse the web and look for interesting algorithms and datastructures to put into my bag of tricks. A year ago I came across the Soft Heap data-structure and learned about near sorting. The idea behind this is that it's possible to break the O(n log n) barrier of compare based sorts if you can live with the fact that...

I'm using Python regexes in a criminally inefficient manner

My goal here is to create a very simple template language. At the moment, I'm working on replacing a variable with a value, like this: This input: <%"TITLE"="This Is A Test Variable"%>The Web <%"TITLE"%> Should produce this output: The Web This Is A Test Variable I've got it working. But looking at my code, I'm running multi...

Search Engines Inexact Counting (about xxx results)

When you search in Google (i'm almost sure that Altavista did the same thing) it says "Results 1-10 of about xxxx"... This has always amazed me... What does it mean "about"? How can they count roughly? I do understand why they can't come up with a precise figure in a reasonable time, but how do they even reach this "approximate" one? I...

Least common multiple for 3 or more numbers

How do you calculate the least common multiple of multiple numbers? So far I've only been able to calculate it between two numbers. But have no idea how to expand it to calculate 3 or more numbers. So far this is how I did it LCM = num1 * num2 / gcd ( num1 , num2 ) With gcd is the function to calculate the greatest common divisor...

Dynamic search and display

I have a big load of documents, text-files, that I want to search for relevant content. I've seen a searching tool, can't remeber where, that implemented a nice method as I describe in my requirement below. My requirement is as follows: I need an optimised search function: I supply this search function with a list (one or more) partia...

Standard algorithm to tokenize a string, keep delimiters (in PHP)

I want to split an arithmetic expression into tokens, to convert it into RPN. Java has the StringTokenizer, which can optionally keep the delimiters. That way, I could use the operators as delimiters. Unfortunately, I need to do this in PHP, which has strtok, but that throws away the delimiters, so I need to brew something myself. This...

Algorithm for finding the maximum difference in an array of numbers

I have an array of a few million numbers. double* const data = new double (3600000); I need to iterate through the array and find the range (the largest value in the array minus the smallest value). However, there is a catch. I only want to find the range where the smallest and largest values are within 1,000 samples of each other. S...

Disk-backed STL container classes?

I enjoy developing algorithms using the STL, however, I have this recurring problem where my data sets are too large for the heap. I have been searching for drop-in replacements for STL containers and algorithms which are disk-backed, i.e. the data structures on stored on disk rather than the heap. A friend recently pointed me toward...

need an algorithm for collapsing netblock ranges into lists of superset ranges

My math-fu is failing me! I need an efficient way of reducing network ranges to supersets, e.g. if I input list of IP ranges: 1.1.1.1 to 2.2.2.5 1.1.1.2 to 2.2.2.4 10.5.5.5 to 155.5.5.5 10.5.5.6 to 10.5.5.7 I want to return the following ranges: 1.1.1.1 to 2.2.2.5 10.5.5.5 to 155.5.5.5 Note: the input lists are not ordered (thoug...

What is the minimum length number the luhn algorithm will work on?

Excluding the check digit, what is the minimum length number the luhn algorithm will work on? My thoughts are that it would work on any number greater than 2 digits (again, excluding the check digit). The reason I ask is this: if i iterates over all digits in the number from right to left. This causes i%2 == 0 (used to find alternate...

Find the prefix substring which gives best compression

Problem: Given a list of strings, find the substring which, if subtracted from the beginning of all strings where it matches and replaced by an escape byte, gives the shortest total length. Example: "foo", "fool", "bar" The result is: "foo" as the base string with the strings "\0", "\0l", "bar" and a total length of 9 bytes. "\0" is ...

Packing rectangles for compact representation.

I am looking for pointers to the solution of the following problem: I have a set of rectangles, whose height is known and x-positions also and I want to pack them in the more compact form. With a little drawing (where all rectangles are of the same width, but the width may vary in real life), i would like, instead of. -r1- -r2-- ...

Is timsort general-purpose or Python-specific?

Timsort is an adaptive, stable, natural mergesort. It has supernatural performance on many kinds of partially ordered arrays (less than lg(N!) comparisons needed, and as few as N-1), yet as fast as Python's previous highly tuned samplesort hybrid on random arrays. Have you seen timsort used outside of CPython? Does it ...

.NET - How can you split a "caps" delimited string into an array?

How do I go from this string: "ThisIsMyCapsDelimitedString" ...to this string: "This Is My Caps Delimited String" Fewest lines of code in VB.net is preferred but C# is also welcome. Cheers! ...