algorithm

Good Linear Algebra Package

Hello, I am implementing some spectral graph algorithms for a project. A large part of this is finding eigenvalues and eigenvectors of large, sparse matrices, as well as multiplying matrices. My question is, what are the fastest libraries that do this? I've been looking at NumPy for Python or JAMA for Java. Are these good, or is t...

How to sort millions of rows of data in a file with less/meagre memory

(From here) I attended an interview last week and this question was asked: How do you sort a billion rows of data in a file with only 640KB of memory in a 8080 processor based machine? No virtual memory, no external disk. I explicitly asked the interviewer if I could use a hard drive, so I can serialize trees as I sort them and then c...

algorithm to pick set of winners using different weights

Hello, I'm attempting to design an algorithm that does the following. Input: I've a set of keys (total n) that are mapped to set of properties. The properties contain the weight for each property and the value for the property. Output: Identify a set of keys that are qualified (total k) based on the set of properties and their ...

Whats the importance of data structures and algorithms for programming?

Possible Duplicate: Why should I learn algorithms? Hello, I'm a curious beginner and I don't understand how algorithms and data structures are useful in programming. Are they crucial for being a good programmer? Why should I learn them and how they actually help me when writing code? Thanks so much! ...

How to efficiently find k-nearest neighbours in high-dimensional data?

So I have about 16,000 75-dimensional data points, and for each point I want to find its k nearest neighbours (using euclidean distance, currently k=2 if this makes it easiser) My first thought was to use a kd-tree for this, but as it turns out they become rather inefficient as the number of dimension grows. In my sample implementation,...

Interview question: dealing with M occurrences among N

Question I've been given at the job interview. I was close to the solution but did not solve it unfortunately. Assume we have a sequence that contains N numbers of type long. And we know for sure that among this sequence each number does occur exactly n times except for the one number that occurs exactly m times (0 < m < n). How do we f...

I have an OpenGL Tessellated Sphere and I want to cut a cylindrical hole in it

Hello, I am working on a piece of software which generated a polygon mesh to represent a sphere, and I want to cut a hole through the sphere. This polygon mesh is only an overlay across the surface of the sphere. I have a good idea of how to determine which polygons will intersect my hole, and I can remove them from my collection, but a...

how to represent a n-byte array in less than 2*n characters

given that a n-byte array can be represented as a 2*n character string using hex, is there a way to represent the n-byte array in less than 2*n characters? for example, typically, an integer(int32) can be considered as a 4-byte array of data ...

generic binary Search in c#

Below is my Generic Binary Search it works ok with the intgers type array it finds all the elements in it . But the Problem Arises when i use a string array to find any string data. It runs ok for the first index and last index elements but i cant find the middle elements. Stringarray = new string[] { "b", "a", "ab", "abc", "c" }; publ...

Find all possible row-wise sums in a 2D array

Ideally I'm looking for a c# solution, but any help on the algorithm will do. I have a 2-dimension array (x,y). The max columns (max x) varies between 2 and 10 but can be determined before the array is actually populated. Max rows (y) is fixed at 5, but each column can have a varying number of values, something like: 1 2 3 4 5 6 7.....

Fundamentals and maths required for algorithms

I have been working on RTOS and Linux driver development for quite some time. Now I am interviewing at semiconductor companies and failing to answer questions about algorithms on strings, and time and space complexity. I have not studied discrete maths and algorithms during my as I have an electronics background. How can I overcome thi...

Calculating Percentiles on the fly

I'm programming in Java. Every 100 ms my program gets a new number. It has a cache with contains the history of the last n = 180 numbers. When I get a new number x I want to calculate how many numbers there are in the cache which are smaller than x. Afterwards I want to delete the oldest number in the cache. Every 100 ms I want to rep...

Image transformation: point to point

Hei! I have an image and on that image I'd like to select a point and tell it to which coordinate it should transform. I'd like to do this for some number points. And when I finish the whole image would transform, so that locality would be considered. The most import thing is that I can choose as many points as I want and that the chos...

What is the best way of sending the data to serial port?

This is related with microcontrollers but thought to post it here because it is a problem with algorithms and data types and not with any hardware stuff. I'll explain the problem so that someone that doesn't have any hardware knowledge can still participate :) In Microcontroller there is an Analog to Digital converter with 10 bi...

How do I remove the longest prefix that appears in an array?

I have two arrays, search and target. I want to find the longest sequence of elements of search that starts from the beginning of search and which also appears in the same consecutive order in target. Then I want to return a copy of target with those elements removed. Here are some examples: search = [4, "apple", 6, "turnip"] target = ...

Represent natural number as sum of squares using dynamic programming

The problem is to find the minimum number of squares required to sum to a number n. Some examples: min[1] = 1 = 12 min[2] = 2 = 12 + 12 min[4] = 1 = 22 min[13] = 2 = 32 + 22 I'm aware of Lagrange's four-square theorem that says that any natural number can be represented as the sum of four squares. I'm trying to solve this using ...

How to get really random number?

Possible Duplicates: Understanding randomness Fastest implementation of a true random number generator in C# Hello. Function: Random rand = new Random(); rand.Next() It gives pseudo random numbers based on time in seconds. How to get really random numbers? I mean totally random not based on system time and some algorithm....

How to manage "speed" in a simple racing game ?

Hi. I'm trying to develop a simple racing 2d game (view top-down) in C#, sdl.net. Now, I'm trying to manage speed, acceleration and brakes of my car. My problem is the algorithm. I have the loop (Events_Tick) executed 50 times per seconds, where the position of my car is processed like the following: private void Events_Tick(object s...

Which parallel sorting algorithm has the best average case performance?

Sorting takes O(n log n) in the serial case. If we have O(n) processors we would hope for a linear speedup. O(log n) parallel algorithms exist but they have a very high constant. They also aren't applicable on commodity hardware which doesn't have anywhere near O(n) processors. With p processors, reasonable algorithms should take O(n/p l...

What is a quick algorithm for converting a matrix of squares into a triangle strip?

Imagine having a 4x4 square, with 16 smaller squares inside of it, with associated data on what the squares should look like (ie., opacity, colour, etc...). Is there an existing, efficient, algorithm, for converting this set of squares into an open-gl compatible triangle strip? ...