algorithm

Howto create combinations of several vectors without hardcoding loops in C++?

I have several data that looks like this: Vector1_elements = T,C,A Vector2_elements = C,G,A Vector3_elements = C,G,T ..... up to ... VectorK_elements = ... #Note also that the member of each vector is always 3. What I want to do is to create all combination of elements in Vector1 through out VectorK. Hence in the end we hope to get t...

How to calculate the 3D line segment of two rectangles?

I am looking for a fast way to calculate the line segment of two given rectangles in 3D. For instance, each 3D rectangle is defined by its four vertices. A solution in any reasonable programming language will do. ...

Detecting forged images with C#?

One of my friends came up with an interesting problem - Assume that we have a set of images in the system. Now, some one might submit a new image by slightly modifying any of the images already submitted, and in that case, the system should report that the submitted image is a forged image. I can think about two solutions. Solution 1 ...

Determining the best k for a k nearest neighbour

I have need to do some cluster analysis on a set of 2 dimensional data (I may add extra dimensions along the way). The analysis itself will form part of the data being fed into a visualisation, rather than the inputs into another process (e.g. Radial Basis Function Networks). To this end, I'd like to find a set of clusters which prim...

permutations of BST

Given an array of integers arr = [5,6,1]. When we construct a BST with this input in the same order, we will have "5" as root, "6" as the right child and "1" as left child. Now if our input is changed to [5,1,6], still our BST structure will be identical. So given an array of integers, how to find the number of different permutations ...

How can I modify the Smith-Waterman algorithm using substitution matrix to align proteins in Perl?

How can I modify the Smith-Waterman algorithm using a substitution matrix to align proteins in Perl? [citations needed] ...

Enumerating All Minimal Directed Cycles Of A Directed Graph

Hello! I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the Tarjan algorithm outputs. For instance, for the directed graph at this wikipedia page, I would like to get c <-> d and d <-> h as tw...

Suggestions for an open source Final Degree Project

Note: I'm not completely sure if this question really belongs to StackOverflow so feel free to vote for closing if you think not. In Spain we have to undertake a final project when we end the computer science degree. The project must not be trivial and can relate to any computer field from Software Engineering to Computer Architecture, ...

Algorithm to flatten peak usage over time?

I have an environment that serves many devices spread across 3 time zones by receiving and sending data during the wee hours of the night. The distribution of these devices was determined pseudo-randomly based on an identification number and a simple calculation using a modulo operation. The result of such a calculation creates an unne...

Given a vector of Lat/Lon pairs, how can I create a vector so that the distance between points is less than or equal to some constant?

Suppose I have an array of coordinates, representing a route. I want to decompose this route so that it contains a point, say every 5 miles. How can I do that? struct Location { double latitude; double longitude; }; vector<Location> route; vector<Location> computeHigherGranularityRoute(const vector<Location>& oldRoute, double ...

Subsequence with maximum sum in array of ints

Given an array of integers, how can you find two indices, i and j, such that the sum of the elements in the indices is maximized, in linear time? ...

Viola-Jones' face detection claims 180k features

I've been implementing an adaptation of Viola-Jones' face detection algorithm. The technique relies upon placing a subframe of 24x24 pixels within an image, and subsequently placing rectangular features inside it in every position with every size possible. These features can consist of two, three or four rectangles. The following exampl...

What are the algorithms used behind filters in image editing softwares?

For example: What algorithm is used to generate the image by the fresco filter in Adobe Photoshop? Do you know some place where I can read about the algorithms implemented in these filters? ...

How can I sort a coordinate list for a rectangle counterclockwise?

I need to sort a coordinate list for a rectangle counterclockwise, and make the north-east corner the first coordinate. These are geographic coordinates (i.e. Longitude, Latitude) in decimal form.1 For example, here are the 4 corners of a rectangle, starting with the north-west corner and moving clockwise: [ { "lat": 34.495239, "lng"...

Create Multi-Dimensional Array With Algorithm Using Data in Single-Dimensional Array

I have an single-dimensional array of PHP objects. Each object has two attributes, one attribute is the object's unique ID and the other is the unique ID of another object in the array that is its parent. For example: array(3) { [0]=> object(stdClass)#1 (2) { ["ID"]=> int(1) ["parentID"]=> int(0) } [1]=> object...

Aligning Shapes on a plan, Algoryhtm

Hello Coders ! I am developing a simple diagram tool with shapes on a plan using flex. First i was using a simple 20*20 grid. But the real cool stuff out their is auto axe magnet effect, that's how i call it at least to see why i mean by that i made a small video of balsamiq. http://screenr.com/clB http://www.balsamiq.com/ As you ca...

Recommendation for a good functional algorithms book

I'm looking for a good algorithms reference for functional programming. I have this book: but all the examples are written in a procedural pseudocode. It's a fantastic book, though! I also have this one: Although all the examples are in Standard ML and Haskell, it's not really a complete reference since it doesn't cover some of th...

How does space partitioning algorithm for finding nearest neighbors work?

For finding the nearest neighbor, Space Partitioning is one of the algorithms. How does it work? Suppose I have a 2D set of points (x and y coordinates), and I am given a point (a,b). How would this algorithm find out the nearest neighbor? ...

What would be the complexity of this color-quantization algorithm?

I started toying with this idea some years ago when I wrote my university papers. The idea is this - the perfect color quantization algorithm would take an arbitrary true-color picture and reduce the number of colors to the minimum possible, while maintaining that the new image is completely indistinguishable from the original with a nak...

Why is the complexity of A* exponential in memory?

Wikipedia says on A* complexity the following (link here): More problematic than its time complexity is A*’s memory usage. In the worst case, it must also remember an exponential number of nodes. I fail to see this is correct because: Say we explore node A, with successors B, C, and D. Then we add B, C, and D to the list of ...