algorithm

Project Euler for programmers?

Duplicate: Websites like projecteuler.net I really like the Project Euler website but its emphasis seems to be more on math than programming. While solutions are given in code, the most efficient tend to rely on knowledge of different areas of math. Is there anything similar that is oriented towards programmers? For (a dumb) examp...

How to cluster objects (without coordinates)

I have a list of opaque objects. I am only able to calculate the distance between them (not true, just setting the conditions for the problem): class Thing { public double DistanceTo(Thing other); } I would like to cluster these objects. I would like to control the number of clusters and I would like for "close" objects to be in t...

Create Random Number Sequence with No Repeats

Duplicate: Unique random numbers in O(1)? I want an pseudo random number generator that can generate numbers with no repeats in a random order. For example: random(10) might return 5, 9, 1, 4, 2, 8, 3, 7, 6, 10 Is there a better way to do it other than making the range of numbers and shuffling them about, or checking the genera...

begin(), end() annoyance in STL algorithms

I like STL algorithms, and prefer use algorithms rather than usual loops. Almost all STL algorithms are usually used as: std::algorithm_name( container.begin(), container.end(), ..... ) container.begin(), container.end() - is one of most popular words pair in my projects. Does anybody have the same problem? How do you Guys solve ...

K Nearest Neighbour Algorithm doubt

Hi, I am new to Artificial Intelligence. I understand K nearest neighbour algorithm and how to implement it. However, how do you calculate the distance or weight of things that aren't on a scale? For example, distance of age can be easily calculated, but how do you calculate how near is red to blue? Maybe colours is a bad example becaus...

algorithm comparison in C, what's the difference?

#define IMGX 8192 #define IMGY 8192 int red_freq[256]; char img[IMGY][IMGX][3]; main(){ int i, j; long long total; long long redness; for (i = 0; i < 256; i++) red_freq[i] = 0; for (i = 0; i < IMGY; i++) for (j = 0; j < IMGX; j++) red_freq[img[i][j][0]] += 1; total = 0; for (i = 0; i < 256; i++) to...

Algorithm to classify a list of products?

I have a list representing products which are more or less the same. For instance, in the list below, they are all Seagate hard drives. Seagate Hard Drive 500Go Seagate Hard Drive 120Go for laptop Seagate Barracuda 7200.12 ST3500418AS 500GB 7200 RPM SATA 3.0Gb/s Hard Drive New and shinny 500Go hard drive from Seagate Seagate Barracuda...

How can I prioritize which feed (out of many) to update?

Let's say I have 500 RSS feeds that need updating very constantly but do not want to check all 500 every minute. What approach or algorithm can best determine which feeds should be updated while others are left for a later time? Assume I can and will save historical data/stats, and that update frequency varies even within the same feed....

Detecting misspelled words

I have a list of airport names and my users have the possibility to enter one airport name to select it for futher processing. How would you handle misspelled names and present a list of suggestions? ...

Utilizing algorithms in academic papers

I'm unclear about legal status of utilizing an algorithm from a published academic paper. Is there an implicit patent over that material? How about open source applications? Would it be ok to implement that algorithm in an open source app, with one of free software licenses? Let's say I have access to paper A which describes algorithm ...

File search algorithms using indexing in linux

I think of implementing a file search program using indexing in linux... I know that there are several other file search programs like beagled. but I am doing this for study purpose... I am struck with how to do indexing.. I have the following idea that I took from maemo-mapper application.. for example if u have file named "suresh" its ...

Generate File Names Automatically without collision

I'm writing a "file sharing hosting" and I want to rename all the files when uploading to a unique name and somehow keep track of the names on the database. Since I don't want two or more files having same name (which is surely impossible), I'm looking for an algorithm which based on key or something generates random names for me. Moreo...

What is the difference between Linear search and Binary search?

What is the difference between Linear search and Binary search? ...

How to represent implicit relationships?

Hi, I am developing an application where I have to deal with an Entity named 'Skill'. Now the thing is that a 'Skill A' can have a certain relevancy with a 'Skill B' (the relevancy is used for search purposes). Similarly 'Skill B' can also be relevant to 'Skill C'. We currently have the following data model to represent this scenario S...

Divide amount by characters present in string, found via regex

Suggestions for an updated title are welcome, as I'm having trouble easily quantifying what I'm trying to do. This is a web-based form with PHP doing the calculations, though this question probably has an algorithmic or language agnostic answer. Essentially, there is an Amount field and a Charge Code field. The Charge code entered r...

Group results created at a similar timestamps

In my project I would like to select records from my database and then group them together by those that occurred at a similar time to the latest record within a certain time range. For example, with a 1 hour time range. If a user created 3 posts between 4:30pm and 5:15pm, 2 posts between 1:15pm and 1:30pm, and 1 post at 10:00am I would...

QuickGraph Dijkstra example.

I have an AdjacencyGraph<string, Edge<string>> which I would like to run AlgorithmExtensions.ShortestPathsDijkstra on, but the QuickGraph documentation isn't the best. Does anyone have an example I can follow? Everything I found on on Google used an observer, which the AlgorithmExtension doesn't require. ...

What searching algorithm/concept is used in Google?

What searching algorithm/concept is used in Google? ...

Can I use arbitrary metrics to search KD-Trees?

I just finished implementing a kd-tree for doing fast nearest neighbor searches. I'm interested in playing around with different distance metrics other than the Euclidean distance. My understanding of the kd-tree is that the speedy kd-tree search is not guaranteed to give exact searches if the metric is non-Euclidean, which means that I ...

Lossless JPEG Rotate (90/180/270 degrees) in Java?

Is there a Java library for rotating JPEG files (90/180/270 degrees) without quality degraded? ...