algorithm

Mapping N-dimensional value to a point on Hilbert curve

I have a huge set of N-dimensional points (tens of millions; N is close to 100). I need to map these points to a single dimension while preserving spatial locality. I want to use Hilbert space-filling curve to do it. For each point I want to pick the closest point on the curve. The Hilbert value of the point (curve length from the star...

How to build a simple recommendation system?

How to build a simple recommendation system? I have seen some algorithms but it is so difficult to implement I wish their is practical description to implement the most simple algorithm? i have these three tables Users userid username 1 aaa 2 bbb and products productid prod...

Mapping Hilbert values to 3D points

I have a set of Hilbert values (length from the start of the Hilbert curve to the given point). What is the best way to convert these values to 3D points? Original Hilbert curve was not in 3D, so I guess I have to pick by myself the Hilbert curve rank I need. I do have total curve length though (that is, the maximum value in the set). ...

Why do you need lots of randomness for effective encryption?

I've seen it mentioned in many places that randomness is important for generating keys for symmetric and asymmetric cryptography and when using the keys to encrypt messages. Can someone provide an explanation of how security could be compromised if there isn't enough randomness? ...

Efficient reordering of large dataset to maximize memory cache effectiveness

I've been working on a problem which I thought people might find interesting (and perhaps someone is aware of a pre-existing solution). I have a large dataset consisting of a long list of pairs of pointers to objects, something like this: [ (a8576, b3295), (a7856, b2365), (a3566, b5464), ... ] There are way too many objects...

Given an audio stream, find when a door slams (sound pressure level calculation?)

Not unlike a clap detector ("Clap on! clap clap Clap off! clap clap Clap on, clap off, the Clapper! clap clap ") I need to detect when a door closes. This is in a vehicle, which is easier than a room or household door: Listen: http://ubasics.com/so/van_driver_door_closing.wav Look: It's sampling at 16bits 4khz, and I'd like to av...

How do I determine the longest similar portion of several strings?

As per the title, I'm trying to find a way to programmatically determine the longest portion of similarity between several strings. Example: file:///home/gms8994/Music/t.A.T.u./ file:///home/gms8994/Music/nina%20sky/ file:///home/gms8994/Music/A%20Perfect%20Circle/ Ideally, I'd get back file:///home/gms8994/Music/, because that's th...

What is validating a binary search tree?

I read on here of an exercise in interviews known as validating a binary search tree. How exactly does this work? What would one be looking for in validating a binary search tree? I have written a basic search tree, but never heard of this concept. Thanks ...

Finding last element of a binary heap

Hello everybody, quoting Wikipedia: It is perfectly acceptable to use a traditional binary tree data structure to implement a binary heap. There is an issue with finding the adjacent element on the last level on the binary heap when adding an element which can be resolved algorithmically... Any ideas on how such an ...

c# GDI Edge Whitespace Detection Algorithm

I am looking for a solution for detecting edge whitespace of c# bitmap, from the c# managed GDI+ library. The images would be either transparent or white, most of the 400x pictures are 8000x8000px with about 2000px whitespace around the edges. What would be the most efficient way of finding out the edges, x, y, height and width coord...

Why does backtracking make an algorithm non-deterministic?

So I've had at least two professors mention that backtracking makes an algorithm non-deterministic without giving too much explanation into why that is. I think I understand how this happens, but I have trouble putting it into words. Could somebody give me a concise explanation of the reason for this? ...

Algorithm for separating nonsense text from meaningful text

I provided some of my programs with a feedback function. Unfortunately I forgot to include some sort of spam-protection - so users could send anything they wanted to my server - where every feedback is stored in a huge db. In the beginning I periodically checked those feedbacks - I filtered out what was usable and deleted garbage. Th...

Using flickr to get photos of a specific location and put together a model

I've read about systems which use the Flickr database of photos to fill in gaps in photos (http://blogs.zdnet.com/emergingtech/?p=629). How feasible is a system like this? I was toying with the idea (not just a way of killing time but as a good addition to something I am coding) of using Flickr to get photos of a certain entity (in this...

How do I round a decimal to a specific fraction in C#?

In C# rounding a number is easy: Math.Round(1.23456, 4); // returns 1.2346 However, I want to round a number such that the fractional part of the number rounds to the closest fractional part of a predefined fraction (e.g. 1/8th) and I'm trying to find out if the .NET library already has this built in. So, for example, if I want to ro...

What are the pitfalls in implementing binary search?

Binary search is harder to implement than it looks. "Although the basic idea of binary search is comparatively straightforward, the details can be surprisingly tricky…" — Donald Knuth. Which bugs are most likely to be introduced into a new binary search implementation? ...

How would you write a program to generate Haiku?

Computer Haiku How would you write a program To make them for you ...

Determining the health/validity of an email address

Routine maintenance on a website often involves verifying that links are valid, flagging bad ones, etc. I know how to match email addresses via a script (especially in the context of a web page where they'd be in mailto: links). My question is how would I verify they're OK without spamming the address? Stripping-off the domain and veri...

Has anyone actually implemented a Fibonacci-Heap efficiently?

Has anyone of you ever implemented a Fibonacci-Heap? I did so a few years back, but it was several orders of magnitude slower than using array-based BinHeaps. Back then, I thought of it as a valuable lesson in how research is not always as good as it claims to be. However, a lot of research papers claim the running times of their algori...

Why is float division slow?

What are the steps in the algorithm to do floating point division? Why is the result slower than say, multiplication? Is it done the same way we do division by hand? By repeatedly dividing by the divisor, subtracting the result to obtain a remainder, aligning the number again and continuing till the remainder is less than a particular ...

Symbolic Mathematics Python?

I am extreamly interested in math and programming and planning to start symbolic math project from scratch. Is this good project idea? Where to start? How should one approach this project? Any good resources? Thanks in advance. ...