algorithm

Any ready-made implementation of Radix Sort for C#?

Preferrably with any non-virus open source license ...

Split String - the Cartesian way.

Given the following string: "foo bar-baz-zzz" I want to split it at the characters " " and "-", preserving their value, but get all combinations of inputs. i want to get a two-dimensional array containing {{"foo", "bar", "baz", "zzz"} ,{"foo bar", "baz", "zzz"} ,{"foo", "bar-baz", "zzz"} ,{"foo bar-baz", "zzz"} ,{"foo", "bar", "baz-z...

Multi Criteria Search Algorithm

Hello, Here's the problem : I've got a huuge (well at my level) mysql database with technical products in it. I ve got something like 150k rows of products in my database plus 10 to 20 others tables with the same amount of rows. Each tables contains a lot of criteria. Some of the criteria are text values, some are decimal, some are just...

Sample data generation from existing data - Algorithm?

Hello, I'm facing a what-am-I-looking-for problem again. I've got tracking data, meaning I tracked myself riding a bike a couple of times on the same track in order to have some test data. So I've got time-distance pairs. I want even more different ones, but want to generate them. I want the virtual test drivers to be both faster and sl...

What's a good algorithm for calculating the area of a quadrilateral?

I see there's a good question already for general polygons here. Are there any simpler or more efficient algorithms specific to quadrilaterals? ...

C#: Removing common invalid characters from a string: improve this algorithm

Consider the requirement to strip invalid characters from a string. The characters just need to be removed and replace with blank or string.Empty. char[] BAD_CHARS = new char[] { '!', '@', '#', '$', '%', '_' }; //simple example foreach (char bad in BAD_CHARS) { if (someString.Contains(bad)) someString = someString.Replace(bad...

two-way keyed encryption/hash algorithm

I am no way experienced in this type of thing so I am not even sure of the keywords (hence the title). Basically I need a two way function encrypt(w,x,y) = z decrypt(z) = w, x, y Where w = integer x = string (username) y = unix timestamp and z = is an 8 digit number (possibly including letters, spec isn't there yet.) ...

Routing "paths" through a rectangular array

I'm trying to create my own implementation of a puzzle game. To create my game board, I need to traverse each square in my array once and only once. The traversal needs to be linked to an adjacent neighbor (horizontal, vertical or diagonal). I'm using an array structure of the form: board[n,m] = byte Each bit of the byte represe...

How does Dijkstra's Algorithm and A-Star compare?

I was looking at what the guys in the Mario AI Competition have been doing and some of them have built some pretty neat Mario bots utilizing the A* (A-Star) Pathing Algorithm. (Video of Mario A* Bot In Action) My question is, how does A-Star compare with Dijkstra? Looking over them, they seem similar. Why would someone use one ove...

what are the fast algorithms to find duplicate elements in a collection and group them?

Say you have a collection of elements, how can you pick out those with duplicates and put them into each group with least amount of comparison? preferably in C++, but algorithm is more important than the language. For Example given {E1,E2,E3,E4,E4,E2,E6,E4,E3}, I wish to extract out {E2,E2}, {E3,E3}, {E4,E4,E4}. what data structure and...

LP Simplex algorithm in C++

I need the robust C++ source code of the simplex algorithm (is a popular algorithm for numerical solution of the linear programming problem). Please, no links to wikipedia. I need good source code in C++, using templates, clear user-friendly names and work very well. Preferably algorithm must check the unstable floating-point calcula...

percentage difference between two text files

I know that I can use cmp, diff, etc to compare two files, but what I am looking for is a utility that gives me percentage difference between two files. if there is no such utility, any algorithm would do fine too. I have read about fuzzy programming, but I have not quite understand it. ...

How to determine if a list is subset of another list?

What is efficient way to determine if a list is a subset of another list? Example: is_subset(List(1,2,3,4),List(2,3)) //Returns true is_subset(List(1,2,3,4),List(3,4,5)) //Returns false I am mostly looking for efficient algorithm and not too concern how the list is stored. It can be stored in array, link list or other data struct...

Replacing nested foreach with LINQ; modify and update a property deep within

Consider the requirement to change a data member on one or more properties of an object that is 5 or 6 levels deep. There are sub-collections that need to be iterated through to get to the property that needs inspection & modification. Here we're calling a method that cleans the street address of a Employee. Since we're changing data ...

finding common prefix of array of strings

I have an array like this $sports = array( 'Softball - Counties', 'Softball - Eastern', 'Softball - North Harbour', 'Softball - South', 'Softball - Western' ); and i would like to find the longest common part of the string so in this instance, it would be 'Softball - '; I am thinking that I would follow the this process $i = 1; // ...

2D bounding box of a sector?

I've googled till I'm blue in the face, and unless I'm missing something really obvious, I can't find any algorithms for calculating the bounding box of a 2D sector. Given the centre point of the enclosing circle, the radius, and the angles of the extent of the sector, what's the best algorithm to calculate the axis-aligned bounding rec...

How do you "get it" when it comes to proofs?

When we start getting into algorithm design and more discrete computer science topics, we end up having to prove things all of the time. Every time I've seen somebody ask how to become really good at proofs, the common (and possibly lazy) answer is "practice". Practicing is all fine if you have the basics down, but how do you get into ...

How to place objects that seem not be comparable in a C++ std::set?

Suppose I want to put objects that identify a server into a stl set. Then I would have to make sure that I also implement operator< for these objects otherwise I would run into a compiler error: struct ServerID { std::string name; // name of the server int port; }; std::set<ServerID> servers; // compiler error, no operator< defined...

How would I figure out if there are other algorithms similar to mine?

In another question, I asked something similar but I ended up just posting my algorithm there and invalidating several answers. I re-ask it here: If I "invented" an algorithm, what's the best way for me to figure out if it's already been published about/patented? ...

Converting integer identifiers to pointers

I have ID values of the type unsigned int. I need to map an Id to a pointer in constant time. Key Distribution: ID will have a value in the range of 0 to uint_max. Most of keys will be clustered into a single group, but there will be outliers. Implementation: I thought about using the C++ ext hash_map stuff, but I've heard thei...