algorithm

Why "Algorithms" and "Data Structures" are treated as separate disciplines?

This question was the last straw; and I've been wondering for a long time about it, Why do people think about "Algorithms" and "Data structures" as about something that can be separated from each other? I see a lot of evidence that they're separated in programmers' minds. they request "Data Structures & Algorithms" books they refer ...

How to detect how far the object on photo is from another objects on that photo?

So for example we have real life photo. how to get (relativly to image dimentions for example) the distance from wall to girls, from girls to trees if all we know ts this picture? Papers with algorithms and\or Open Source programs doing this would be appreciated. As for me Code is Better than just pure algorithm. So if you give algori...

PostgreSQL: Auto-partition a table

Hi, I have a huge database which holds pairs of numbers (A,B), each ranging from 0 to 10,000 and stored as floats. e.g., (1, 9984.4), (2143.44, 124.243), (0.55, 0), ... Since the PostgreSQL table which stores these pairs grew quite large, I have decided to partition it into inheriting sub-tables. I intend to create 100 such tables, ...

How to detect a image texture?

So we have a photo like this How to detect that a red wall has a white figure painted on it and that that white figure is a texture and than how to cut that wall from the picture? I need an algorithm for performing such operation programaticly (not by hand) ...

How does one convert 16-bit RGB565 to 24-bit RGB888?

I’ve got my hands on a 16-bit rgb565 image (specifically, an Android framebuffer dump), and I would like to convert it to 24-bit rgb888 for viewing on a normal monitor. The question is, how does one convert a 5- or 6-bit channel to 8 bits? The obvious answer is to shift it. I started out by writing this: puts("P6 320 480 255"); uint16_...

Algorithm to create an image of an elliptical brush?

I need to be able to accept elliptical(computed) brush parameters such as spacing, hardness, roundness, angle and diameter and then compute a bitmap image based on those attributes. Does anyone know the algorithm(or where I can find it) to do this? I have limited experience in graphics programming and I have been unable to find it so f...

crossing edges in the travelling salesman problem

Does there exist a travelling salesman problem where the optimal solution has edges that cross? The nodes are in an x-y plane, so crossing in this case means if you were to draw the graph, two line segments connecting four separate nodes would intersect. ...

What sort of graph to represent this business logic decision tree?

How would I usually represent this business logic in a graph? A is true if B is true or C is true C is true if D is true and E is true and F is true X is true if Y is true and C is not true Is it a directed acyclic graph? How do I represent the 'and'/'or' logic in the graph, in graph terminology? (I am looking for the corr...

Provable planarity of flowcharts

I have a question: is there any reference (e.g. paper) with a proof of the planarity of flowchart layouts? Can anyone suggest an algorithm for generating flowchart (planar) layouts? I know that there are some code-to-flowchart tools out there, but i'm unaware of their internals. ...

Graph coloring Algorithm

From wiki http://en.wikipedia.org/wiki/Graph_coloring In its simplest form, it is a way of coloring the vertices of a graph such that no two adjacent vertices share the same color; this is called a vertex coloring. Similarly, an edge coloring assigns a color to each edge so that no two adjacent edges share the same col...

Fermat factorization method limit

I am trying to implement Fermat's factorization (Algorithm C in The Art of Computer Programming, Vol. 2). Unfortunately in my edition (ISBN 81-7758-335-2), this algorithm is printed incorrectly. what should be the condition on factor-inner loop below? I am running the loop till y <= n [passed in as limit]. (if (< limit y) 0 (factor-inn...

finding two most distant elements in a binary tree

I am looking for an algorithm that could find the two most distant elements in a binary tree, not looking for any special language, just for the algorithm. Thanks. ...

Heuristic algorithm for load balancing among threads.

I'm working on a multi-threaded program where I have a number of worker threads performing tasks of unequal length. I want to load-balance the tasks to ensure that they do roughly the same amount of work. For each task Ti I have a number ci which provides a good approximation to the amount of work that is required for that task. ...

Finding a Minimum Equivalent Graph of a Digraph

I'm looking for an implementation preferably in Java of an algorithm for finding a Minimum Equivalent Graph of a Digraph (http://portal.acm.org/citation.cfm?id=321526.321534). Even better would be an implementation of "Approximating the minimum equivalent digraph" http://cat.inist.fr/?aModele=afficheN&amp;cpsidt=3634076 (requires ACM m...

mysql/stats: Weighting an average to accentuate differences from the mean

This is for a new feature on http://cssfingerprint.com (see /about for general info). The feature looks up the sites you've visited in a database of site demographics, and tries to guess what your demographic stats are based on that. All my demgraphics are in 0..1 probability format, not ratios or absolute numbers or the like. Essenti...

How can I create set of small bounding boxes given a large area?

Given a large bounding box (say 1 km square), I want to divide this area into a set of smaller bounding boxes to form a grid pattern. I know there are some Earth geometry issues to contend with where. Can anyone help? I'm doing with with Ruby and I'm working with the excellent GeoKit library. Thank you! ...

Evenly select N elems from array

Hi, I need to evenly select n elements from an array. I guess the best way to explain is by example. say I have: array [0,1,2,3,4] and I need to select 3 numbers.. 0,2,4. of course, if the array length <= n, I just need to return the whole array. I'm pretty sure there's a defined algorithm for this, been trying to search, and I took...

Archery game programming algorithm

I need the algorithm to animate the arrow based on 2 parameters, angle while shooting and power while drawing the bow. Ive tried to use y=asinx but it works only when shooting in up direction. Doesnt work well while shooting with straight or down direction. Thanks. ...

Easiest way of checking if a string consists of unique characters?

I need to check in Java if a word consists of unique letters (case insensitive). As straight solution is boring, I came up with: For every char in a string check if indexOf(char) == lastIndexOf(char). Add all chars to HashSet and check if set size == string length. Convert a string to a char array, sort it alphabetically, loop through ...

Search algorithm for a sorted double linked list

As a learning excercise, I've just had an attempt at implementing my own 'merge sort' algorithm. I did this on an std::list, which apparently already had the functions sort() and merge() built in. However, I'm planning on moving this over to a linked list of my own making, so the implementation is not particuarly important. The problem ...