algorithm

C# calling CMPH BDZ

Hello, Does anybody have any experience of using the CMPH hashing library to create specific hash functions callable from c#. Any help would be appreciated Does anybody know of any state of the art hashing algorithms that can be called from c# and don't explicity offer a copyleft licence. Thanks Bob. ...

Levenshtein distance combination

LD = Levenshtein Distance Just doing a few examples on paper, this seems to work, but does anyone know if this is always true? Lets say I have 3 strings BOT BOB BOM LD(BOT,BOB) = 1 and LD(BOB,BOM)=1 then LD(BOT,BOM)=max(LD(BOT,BOB) , LD(BOB,DOM))=1 OR BAAB BBAB BCCD LD(BBAB,BAAB) = 1 and LD(BBAB,BCCD)=3 then LD...

fastest algorithm to get average change

I have a sorted dictionary where the key is a date and the value is a integer that represents time left. i have 3 years worth of data so it would be something like Key: 2009-1-1, Value: 100 Key: 2009-1-2, Value: 97 Key: 2009-1-3, Value: 92 Key: 2009-1-4, Value: 87 ... ... Key: 2009-1-30, Value: 0 I would like to calculate average chan...

Position of connected points in space

Hi, A-B-C-D are 4 points. We define r = length(B-C), angle, ang1 = (A-B-C) and angle ang2 = (B-C-D) and the torsion angle tors1 = (A-B-C-D). What I really need to do is to find the coordinates of C and D provided that I have the new values of r, ang1, ang2 and tors1. The thing is that the points A and B are rigidly connected to each ot...

Multidimensional array serialization

function source_of (array, up_to_dimension) { // Your implementation } source_of([1, [2, [3]]], 0) == '[1, ?]' source_of([1, [2, [3]]], 1) == '[1, [2, ?]]' source_of([1, [2, [3]]], 2) == '[1, [2, [3]]]' source_of([532, 94, [13, [41, 0]], [], 49], 0) == '[532, 94, ?, ?, 49]' I have very huge multidimensional array and I want to ser...

Efficient, correct and optimized algorithm to find intersection between two lines.

What is the most efficient algorithm to find intersection point between two lines? You are given four points A, B , C , D. Find the intersection point between AB and CD. Optimize the algorithm as much as you can. There are two approach for this, one is using dot product and another is using slope intercept form for line. which one is ...

Algorithm to minimize the space complexity of a sparse matrix?

When storing and manipulating sparse matrices on a computer (zeros and ones), it is beneficial and often necessary to use specialized algorithms and data structures that take advantage of the sparse structure of the matrix. Operations using standard matrix structures and algorithms are slow and consume large amounts of memory when applie...

What is the technology behind bing? Its own version of map-reduce algorithm or something else?

Bing's search hits are quite impressive, has Microsoft not let anyone in on behind the scenes of their search technology? Tried http://www.discoverbing.com but couldn't find the answer to my question. ...

Minimum perpendicular Distance of a point to a line in 3D plane algorithm

How to find the minimum perpendicular distance of point from a line in 3D plane? Please give me the logic and I will try to code on myself. Please let me know how to do it in terms of x,y,z that is in terms of coordinate systems. I am finding it a bit difficult to find the right solution which will be easy from a coding point of view....

Shifting elements in an array C++

Hello, I've developed a method called "rotate" to my stack object class. What I did was that if the stack contains elements: {0,2,3,4,5,6,7} I would needed to rotate the elements forwards and backwards. Where if i need to rotate forwards by 2 elements, then we would have, {3,4,5,6,7,0,2} in the array. And if I need to rotate backwards,...

How can a large Array be split into smaller arrays?

Given a large array how can it be split into smaller arrays with the size of the smaller arrays specified as an argument of the method? For instance, given numbers, what would Split's implementation be? int[] numbers = new int[7845]; int[][] sectionedNumbers = numbers.Split(1000); sectionedNumbers.Length; //outputs 8 sectionedNumbers...

Walking a tree, parent first

What is the best way to visit all the nodes of a linked tree (all nodes have references to parent and all children, root nodes have null as parent), so that no node is visited before any of its ancestors? Brownie points for non-recursive. ...

How do I swap elements in a List?

I am trying to learn about data structures and algorithms on my own. I wrote my own double-linked list in C and now I want to write some algorithms to perform on the list. What is the preferred way to swap list items? Is it better to swap the content or to rearrange the pointers which point to the next and previous list item? ...

Broad-phase collision detection methods?

I'm building a 2D physics engine and I want to add broad-phase collision detection, though I only know of 2 or 3 types: Check everything against everything else (O(n^2) complexity) Sweep and Prune (sort and sweep) something about Binary Space Partition (not sure how to do this) But surely there's more options right? what are they? A...

Algorithm to decrypt data with drawn strokes

Let's say I have an encrypted file on an iPhone and every time I want to decrypt it, I want to "draw" a decryption symbol instead of having to use a keyboard to type it in. If you request from the user to draw a symbol to decrypt a file every time it is needed (e.g. every time they launch your application) they would probably prefer it ...

Efficient way to compare two strings (ordering of characters irrelevant)

I am trying to come up with an algorithm to compare two strings. It would register a match any words that contain the same letters. For example rent and tern would be equivalent because they both contain the letters r,e,n,t. EDIT I apologize for being so vague. The comparison is going to be made on two sets of a few thousands of words h...

Null pointer exception error

When I run my program I get this error nullPointerException: null. import model.*; import java.awt.*; import java.awt.event.*; import java.text.*; import javax.swing.*; public class ButtonPanel extends JPanel implements View { private Prison prison; private LeftInputPanel leftInput; private DaysPanel days; private MonthsPanel months; ...

How to obtain all subsequence combinations of a String (in Java, or C++ etc)

Let's say I've a string "12345" I should obtain all subsequence combinations of this string such as: --> 1 2 3 4 5 --> 12 13 14 15 23 24 25 34 35 45 --> 123 124 125 234 235 345 --> 1234 1235 1245 1345 2345 --> 12345 Please note that I grouped them in different number of chars but not changed their order. I need a method/function does...

Given a set of points, how do I find the two points that are farthest from each other?

I could compute the distance between each point and take the largest but that doesn't sound like a very efficient way to do it when there are a large (> 1000) number of points. Note: This is for iPhone so I don't have a ton of processing power. ...

How can I maximally partition a set?

I'm trying to solve one of the Project Euler problems. As a consequence, I need an algorithm that will help me find all possible partitions of a set, in any order. For instance, given the set 2 3 3 5: 2 | 3 3 5 2 | 3 | 3 5 2 | 3 3 | 5 2 | 3 | 3 | 5 2 5 | 3 3 and so on. Pretty much every possible combination of the members of the set....