algorithm

Rijndael algorithm

hi all, I want to work on Rijndael algorithm using c#. Can anybody help me for this please. ...

Find the shortest Path between two nodes (vertices)

I have a list of interconnected edges (E), how to find the shortest path connecting from one vertex to another? I am thinking about using lowest common ancestors, but the edges don't have a clearly defined root, so I don't think the solution works. Shortest path is defined by the minimum number of vertexes treversed. Note: There coul...

General Design Question

Hi, I have a general design question: There is a junction, with four roads connecting to it. Each road has 2 lanes. What would be the best way to design a program to handle such junction. It should allow 2 cars 2 go through the junction if they don't interfere each other. and 1 car came in before the other, and they both should use the ...

Find the number of unique longest common subsequences

For 2 strings, I want to find the number of distinct LCS's. I read on wiki on how to print all LCS's but how to check that they are distinct? The hash table is not feasible as my input string each can be 1500-2000 characters long so maximum number of LCS's can be 2000 choose 1000 ...

Algorithm wanted: Find all words of a dictionary that are similar to words in a free text

We have a list of about 150,000 words, and when the user enters a free text, the system should present a list of words from the dictionary, that are very close to words in the free text. For instance, the user enters: "I would like to buy legoe toys in Walmart". If the dictionary contains "Lego", "Car" and "Walmart", the system should p...

Shell script sort list

I have a list with the following content: VIP NAME DATE ARRIVE_TIME FLIGHT_TIME 1 USER1 11-02 20.00 21.00 3 USER2 11-02 20.45 21.45 4 USER2 11-03 20.00 21.30 2 USER1 11-04 17.20 19.10 I want to sort this and similar lists with a shell script. The result should be a new list with lines that do not collide....

Standard Normal Distribution z-value function in C#

I been looking at the recent blog post by Jeff Atwood on Alternate Sorting Orders. I tried to convert the code in the post to C# but I ran into an issue. There is no function in .NET that I know of that will return the z-value, given the percentage of area under the standard normal curve. The recommended values to use for the algorithm a...

Algorithm for 2-Satisfiability problem

Can anyone explain the algorithm for 2-satisfiability problem or provide me the links for the same? I could not find good links to understand it. ...

Efficient storage of external index of strings

Say you have a large collection with n objects on disk and each one has a variable-sized string. What are common practices of efficient ways to make an index of those objects with plain string comparison. Storing the whole strings on the index would be prohibitive in the long rundue to size and I/O, but since disks have a high latency st...

Calculating distance between two points using pythagorean theorem

I'd like to create a function that calculates the distance between two pairs of lat/longs using the pythag theorem instead of the haversine great-circle formula. Since this will be over relative short distances (3km), I think this version that assumes a flat earth should be OK. How can I do this? I asked the internet and didn't come up w...

2-Satisfiability problem-Whether a unique truth assignment exists or not

I have a problem which is an extension of 2-SAT problem. In standard 2-SAT problem, we can find any of the truth assignments which depends on the ordering of vertices we choose. I want to check whether there exists one and only one truth assignment(i.e only one combination) for which the expression is satisfiable. The number of literals ...

List<T> and ArrayList default capacity

I have been looking at .NET's List and ArrayList implementations with Reflector. When looking at the Add(T item) I ran across this.EnsureCapacity(this._size + 1): public void Add(T item) { if (this._size == this._items.Length) { this.EnsureCapacity(this._size + 1); } this._items[this._size++] = item; this._ve...

How to create a system with 1500 servers that deliver results instantaneously?

I want to create a system that delivers user interface response within 100ms, but which requires minutes of computation. Fortunately, I can divide it up into very small pieces, so that I could distribute this to a lot of servers, let's say 1500 servers. The query would be delivered to one of them, which then redistributes to 10-100 other...

How port WaitForMultipleObjects to Java?

Hello fellows! I have some code in C++ for Windows and I intend to port it to Java. But unfortunately it is not so easy as I thought. Could someone help me, please? Please, take a look at algorithm: HANDLE hExitEvent; HANDLE hDataAvailabeEvent; while(true) { WaitForMultipleObjects(); if (hExitEvent is set) break; if (hDataA...

find match between 2 sql queries

I have two queries from v$sqlarea. For example query 1: select * from employee emp where emp.eid = 5 query 2: select * from employee v where v.eid = 15 Both are exactly the same in structure. but they will be compiled separately each time.. I need to match such queries that vary only by alias names or bind variables. The inbuilt ...

Finding the number of solutions of 2 SAT

I want an algorithm to know whether there exists more than one solution for 2-satisfiability problem say for 1000 literals assuming it is satisfiable. Please explain. ...

Combined area of overlapping circles

I recently came across a problem where I had four circles (midpoints and radius) and had to calculate the area of the union of these circles. Example image: For two circles it's quite easy, I can just calculate the fraction of the each circles area that is not within the triangles and then calculate the area of the triangles. But...

Automatically finding numbering patterns in filenames

Hi all, Intro I work in a facility where we have microscopes. These guys can be asked to generate 4D movies of a sample: they take e.g. 10 pictures at different Z position, then wait a certain amount of time (next timepoint) and take 10 slices again. They can be asked to save a file for each slice, and they use an explicit naming pat...

Confused in DDA algorithm , need some help

Hi Friends, I need help regarding DDA algorithm , i'm confused by the tutorial which i found online on DDA Algo , here is the link to that tutorial http://i.thiyagaraaj.com/tutorials/computer-graphics/basic-drawing-techniques/1-dda-line-algorithm Example: xa,ya=>(2,2) xb,yb=>(8,10) dx=6 dy=8 xincrement=6/8=0.75 yincrement=8/8=1 ...

How would I find a book in a large library?

I found the following question while preparing for an interview: You are in a very huge library that has no computer access, and you're looking for one particular book. You look up where the book suppose to be from the card catalog, and went to shelf X to find it. However the book is not there. There is only on...