algorithm

Generic collection algorithms in C#

Dear ladies and sirs. Is there a library of generic collection algorithms for .NET? I would like to be able to write something like this: IList<T> items = GetItemsFromSomeWhere(); Algorithms<T>.Sort(items); // // bla bla bla // T item = GetItemSomwHow(); int i = Algorithms<T>.IndexOf(items, item); Note, that items is not List<T>, oth...

Algorithm For Generating Unique Colors

I am looking for an algorithm that will generate a series of colors so that the colors will be as widely distributed as possible (so they won't easily be mixed up). I have a series of objects that have IDs that count up from 1. I would like to represent each of these with a different, aesthetically pleasing, color that won't get easily...

Object Syncronization Between Multiple Clients Algorithm

I'm making a small peer-to-peer app that holds a common collection of objects. This isnt a question about the socket comms to transfer the objects as I have that sorted. To start with I dont have to worry about conflicts as the clients can only add to the object collection. But I'm struggling to work out in my head how the clents negoti...

How to create an optimized packaging function in python?

So I have been given the task to create a shipping module for a webshop system. It may be a bit overkill, but I would really like to create one that can figure out how to pack parcels in the most optimized way. Having learned programming simply by doing it, this is an area where I have no knowledge - yet! Anyways I can just give short de...

Should use an insertion sort or construct a heap to improve performance?

We have large (100,000+ elements) ordered vectors of structs (operator < overloaded to provide ordering): std::vector < MyType > vectorMyTypes; std::sort(vectorMyType.begin(), vectorMyType.end()); My problem is that we're seeing performance problems when adding new elements to these vectors while preserving sort order. At the moment ...

Predicting missing data values in a database

I have a database, consisting of a whole bunch of records (around 600,000) where some of the records have certain fields missing. My goal is to find a way to predict what the missing data values should be (so I can fill them in) based on the existing data. One option I am looking at is clustering - i.e. representing the records that ar...

square puzzle solution

Question: given an integer number n, print the numbers from 1 up to n2 like this: n = 4 result is: 01 02 03 04 12 13 14 05 11 16 15 06 10 09 08 07 How do you solve it (apart from the solution provided in the link below)? http://www.programmersheaven.com/mb/CandCPP/81986/81986/problem-in-making-ap-c++-program/?S=B20000 I'm looking ...

Sorting two-way cell connections with priority

I have a two dimensional grid of cells. In this simulation, cells may request to switch position with another cell. The request also has a priority. The problem is that Im having a hard time coming up with a good way to structure this. If A wants to switch with B, and B also wants to switch with A, they currently can be switched and swi...

White balance algorithm

I'm doing some image processing and I need an automatic white balancing algorithm thats not too cpu intensive. Any recommendations? edit: and if it's relevant to efficiency, I'll be implementing it in java with color images as an array of integers. ...

Mapping a branching tile path

I'm working on a game (and have asked a couple questions on it already), and now I have another question to ask of you guys. The level format in this game is set up as a tilemap of Uint16's (I'm using SDL) which are indices into an array of tilemapData structs. One of the bits of the tilemapData struct is the isConductive bit/boolean. ...

What kind of a job/position could be a fit to a recent graduate with M.Sc in Algorithms & Logic?

Hi guys, I got my masters degree in Algorithms and Logic (I also have a bachelors in Math) six months ago and since then I have been looking for a job. I am specialized in Graph Theory (thesis + 2 years of research) and I was mostly trained in algorithm design (via pseudocodes) and techniques, running times/space complexity classes / hi...

How to eliminate duplicates from a linked list of unicode characters, without using any extra memory

“Find a recurring element in a linked list of unicode characters. If a unicode character/s is found to have a duplicate then just delete that repeating node and adjust the list. The constraint was to not to use any extra memory.” My answer: Assuming that the unicode char doesn't include surrogate pair char As I am using c# I don't know...

Minimization of f(x,y) where x and y are integers

Hi I was wondering if anyone had any suggestions for minimizing a function, f(x,y), where x and y are integers. I have researched lots of minimization and optimization techniques, like BFGS and others out of GSL, and things out of Numerical Recipes. So far, I have tried implenting a couple of different schemes. The first works by pick...

How would you implement a perfect line-of-sight algorithm?

Disclaimer: I'm not actually trying to make one I'm just curious as to how it could be done. When I say "Most Accurate" I include the basics wall distance light levels and the more complicated Dust in Atmosphere rain, sleet, snow clouds vegetation smoke fire If I were to want to program this, what resources should I look into an...

Sort array in ascending order while minimizing "cost"

I'm taking comp 2210 (Data Structures) next semester and I've been doing the homework for the summer semester that is posted online. Until now, I've had no problems doing the assignments. Take a look at assignment 4 below, and see if you can give me a hint as to how to approach it. Please don't provide a complete algorithm, just an app...

Algorithm for music imitation?

I'm interested in automatic music making. I was thinking about a program that is fed a large number of 1-bar arpeggios (= fixed length sequences of notes, for simplicity) and generates its own sequences, based on what it learnt. To start with, I know I could use letter (digram? trigram?) frequency analysis, only applied to note pitches,...

Is it worth it to look at a method that does exactly the opposite of what you want to do?

For example take this paper[PDF]. If I wanted to add Weather degradation into a clear photograph would it be worth it to look at that paper and try to reverse it? Also is there any specific approach to reversing an algorithm if it is at all possible? ...

Programmatically creating vector arrows in KML

Does anyone have any practical examples of programmatically drawing icons as vectors in KML? Specifically, I have data with a magnitude and an azimuth at given coordinates, and I would like to have icons (or another graphical element) generated based on these values. Some thoughts on how I might approach it: Image directory (a brute f...

Finding edge in weighted graph

I have a graph with four nodes, each node represents a position and they are laid out like a two dimensional grid. Every node has a connection (an edge) to all (according to the position) adjacent nodes. Every edge also has a weight. Here are the nodes represented by A,B,C,D and the weight of the edges is indicated by the numbers: A ...

Implementing authentication in an webpage through WinForms app

and here comes the situation... A customer has installed my super dooper winforms application. The username and password are authenticated on the app startup with my MSSQL server. I would like to redirect the user in my webpage and have him as "logged-in" when he clicks the "Update subscription" button within my app (without the need o...