algorithm

Bidirectionnal Bubble Sort in Java?

I need to implement the bidirectional bubble sort in my code. In other words in will go from left to right first carrying the largest value. But when it reaches out, it should reverse and go from right to left carrying the smallest value. I am advised to to implement another out index in addition the current one. This is what I have...

Algorithm for a 3-dimensional parity-check code ?

This explains it but only for 2 dimensions : http://en.wikipedia.org/wiki/Multidimensional_parity-check_code While for a 2-dimensional it's rather easy, how would you code it for 3 or more dimensions ? Thank you. ...

Wall detection algorithm

What would be the sanest/simplest approach to do wall detection on static images? It doesn't have to be in real-time. Right now I'm using corner detection, but is there a simpler way to detect only the walls and discard all the smaller irrelevant corners detected in foreground objects? edit Target images are standard pictures of indoo...

Longest palindrome prefix

How to find the longest palindrome prefix of a string in O(n)? ...

How can I change an Objects position in a list by changing his content instead of his orderNumber (need an algorithm)?

I'm sorry I couldn't think of a more precise title, but hopefully I'll manage to explain the problem here. I have an Object (DataType) which acts something like the HTML SELECT element, it's a container for predefined values (DataTypeValues) . The values are set in a specific order and in the database, the primary key consists of the Dat...

dijkstra's algorithm with negative edges on a directed graph

What if the only negative edge costs are coming from the initial node? Will the algorithm still work? I feel like yes because I can't think of a counter-example, but I'm having trouble proving it. Anyone have a counter-example? Negative edges are a problem for Dijkstra's because there's no guarantee that the edge you pick produces the ...

iphone, Image processing

I am building an application on night vision but i don't find any useful algorithm which I can apply on the dark images to make it clear. Anyone please suggest me some good algorithm. Thanks in advance ...

Solve the problem with O(nlogn) time

Let A[1]<=A[2]<=....<=A[n]. Let X be an arbitrary number. Give an algorithm find all pairs of A[i] and A[j] such that A[j] - A[i] >= X. All numbers are positive integers. If you want to see the original problem. Here it is: Let P = {p1; p2; ; pn} be a set of n points in a 2-dimensional space, where pi = (xi; yi) for each i. Let D =...

Stable Matching Problem

I am currently reading an Algorithm's book and came across the Stable Matching Problem. And a question came to mind that I'm curious about, but the book doesn't answer. In every SMP is it possible to always have one pair where each prefers the other one the most? Like in the classic marriage example. Is there always a pair that have one ...

Find largest number with all contiguous triples being unique primes

Find largest number with all contiguous triples being unique primes If the digits of the answer are pqrstu...xyz then pqr, qrs, rst ... etc are all unique primes. As expected, extra points for speed, conciseness, and other good things. I can run Python/C/C++/Java on my comp and will try to update the answers with the running time of...

Simple algorithm performance

Hi, Can you please distinguish which formula would be computationally more effective: Sn = 1/n * ∑(Xi - C)² | sum "i" till "n" or Sn = 1/n * ∑Xi² - C² | sum "i" till "n" C is const. First one has n squares and second one (n+1) squares Thanks in advance ...

Inserting errors into data

LCD4Linux has some code where it inserts "errors" into some data regarding status bars. Character LCDs are usually limited to 8 special characters that are basically 7x8 pixel fonts, and you can draw on each font with whatever shapes you want within that space. Anyone know where I can find information on similar algorithms? Here's the ...

Is there a way to find sum of digits of 100! ?

Hey guys , i know there is a way of finding the sum of digits of 100!(or any other big number's factorial) using Python . But i find it really tough when it comes to c++ as the the size of even LONG LONG is not enough. EDIT: i just want to know if there is some other way , i am not aware of which can do the needful. thanks see guys i ge...

Template matching - Image subtraction

I have a project where I am required to subtract an empty template image from an incoming user filled image. The document type is a normal Bank cheque. The aim is to extract the handwritten fields from it by subtracting one image from the empty template image. The issue what i am facing is in aligning these two images, as there is sca...

What's the difference between Minimmum Spanning Tree and Travelling Salesman Problems

please be precise. ...

Flagging possible identical users in an account management system

Hi, I am working on a possible architecture for an abuse detection mechanism on an account management system. What I want is to detect possible duplicate users based on certain correlating fields within a table. To make the problem simplistic, lets say I have a USER table with the following fields: Name Nationality Current Address Logi...

Splitting Selection algorithm

Hi all. I got a problem of selecting triangles in a model with a particular way. The problem is simple enough : User have a model (made from triangles) , on that model define some margine line (cutting line if you wish), and after based on array of the verticies of the margin line I would like to select one part of the model or another...

Implementing HexQ Algorithm

Does anyone know if there's an open source implementation (in any language) of the HexQ algorithm for hierarchy discovery in reinforcement learning, or something like it? I'd like to evaluate it in different domains but I'm having trouble understanding how to implement it from the paper's description. ...

How to align shapes together? (Geometrical Best-Fit Algorithm)

I'm working with mecanical engineers who rely on 3D modeling software. These softwares have a "Best Fit" feature. It allows you to acquire data with a sensor (like a 3D scanner) and align the mesured data with a CAD Drawing. I'd like to know how such an algorithm can work! In simpler words, imagine that you have 2 NEARLY identical tria...

Understanding the Math Behind PageRank and Similar Algorithms

I've looked at a bunch of resources provided by similar questions asked on this site, the most helpful so far has been found in this discussion, and the resources linked here: PageRank Explained.. While this provides a detailed overview, I'm looking for something a bit more specific. While I realize there are other factors in play, and...