algorithm

Circular Match

I have a database with three tables: userid_tbl, need_tbl, have_tbl create table userid_tbl (user_id varchar2(15) not null primary key); create table need_tbl (user_id varchar2(15) not null, have_item varchar2(100) not null, foreign key (user_id) references userid_tbl (user_id) ); create table have_tbl (user_id varchar2(15) not null,...

Calculating coordinates given a bearing and a distance

I am having problems implementing the function described here here. This is my Java implementation: private static double[] pointRadialDistance(double lat1, double lon1, double radianBearing, double radialDistance) { double lat = Math.asin(Math.sin(lat1)*Math.cos(radialDistance)+Math.cos(lat1) *Math.sin(radialDistance)*Math.co...

What algorithm to use to determine minimum number of actions required to get the system to "Zero" state?

This is kind of more generic question, isn't language-specific. More about idea and algorithm to use. The system is as follows: It registers small loans between groups of friends. Alice and Bill are going to lunch, Bill's card isn't working, so Alice pays for his meal, $10. The next day Bill and Charles meet each other on a railway sta...

Is there an edit distance algorithm that takes "chunk transposition" into account?

I put "chunk transposition" in quotes because I don't know whether or what the technical term should be. Just knowing if there is a technical term for the process would be very helpful. The Wikipedia article on edit distance gives some good background on the concept. By taking "chunk transposition" into account, I mean that Turing, Al...

Bipartite Matching

How can I implement a bipartite matching algorithm (probably based on a max-flow algorithm) in C or C++ ? To be specific, I have this input in a file: (1,3) (1,5) (2,5) (M,F) --> where M represents id of MALE and F is id of FEMALE. I need to find the maximum number of matches and show matched couples. Like: matches: 1&3 , 2&5 I h...

What is the difference between an Algorithm and a Method

How do you differentiate between an algorithm and a method? Why dont we call Newton's Method or Ford-Faulkerson method Algorithms? What are a properties of a good algorithm and what qualifies a method as an algorithm? ...

How to picture "for" loop in block representation of algorithm

I have probem / strange question, i got algorithm with few "for" loops and now i need to do block scheme of this algorithm. I know how to picture "while" loop, but is this acceptable to represent "for" loop using "while" and at this point make difference between souce code and algorithm?. Ofcourse assuming that all "for" loops are righ...

What is the difference between a Generative and Discriminative Algorithm?

Please help me understand the difference between a Generative and Discriminative Algorithm keeping in mind that I am just a beginner. ...

Looking a data structure that is a Map but in which keys can be values, values can be keys

A Map maps from keys to values and provides quick access based on the knowledge of the key. Does there exist a data structure like Maps which supports both key to value and value to key access? Sometimes I may want to derefence the Map via the value, while other times by the key. ...

execution time calculation

How to you calculate Execution time of your C#, Windows Application. Are there any industry recognized methods? ...

How can I sort numbers lexicographically?

Here is the scenario. I am given an array 'A' of integers. The size of the array is not fixed. The function that I am supposed to write may be called once with an array of just a few integers while another time, it might even contain thousands of integers. Additionally, each integer need not contain the same number of digits. I am supp...

What is an efficient way to go beyond a greedy algorithm

The domain of this question is scheduling operations on constrained hardware. The resolution of the result is the number of clock cycles the schedule fits within. The search space grows very rapidly where early decisions constrain future decisions and the total number of possible schedules grows rapidly and exponentially. A lot of the po...

What can I use to determine similar words or keywords?

Does anyone know of a "similar words or keywords" algorithm available in open source or via an API? I am looking for something sort of like a thesaurus but smarter. So for example: intel returns: processor, i7 core chip, quad core chip, .. etc Any ideas or even something to point me in the right direction in C#? ...

Algorithm for Comparing Words (Not Alphabetically)

Hello, I need to code a solution for a certain requirement, and I wanted to know if anyone is either familiar with an off-the-shelf library that can achieve it, or can direct me at the best practice. Description: The user inputs a word that is supposed to be one of several fixed options (I hold the options in a list). I know the input ...

Number base conversion as a stream operation

Is there a way in constant working space to do arbitrary size and arbitrary base conversions. That is, to convert a sequence of n numbers in the range [1,m] to a sequence of ceiling(n*log(m)/log(p)) numbers in the range [1,p] using a 1-to-1 mapping that (preferably but not necessarily) preservers lexigraphical order? I'm particularly in...

What are eigen values and expansions?

What are eigen values, vectors and expansions and as an algorithm designer how can I use them? EDIT: I want to know how YOU have used it in your program so that I get an idea. Thanks. ...

How to select proper java data structure to model a 1-n relational mapping ?

Scenario I'm going to be as succinct as possible. Basically with reference to this classdiag, I have a facade which manages a list of SocketManager ( which manages one Socket connection). Each SocketManager logs in to a remote server using a unique SocketUserId. Furthermore, each SocketManager will accept messages from clients destined ...

How do 20 questions AI algorithms work?

Simple online games of 20 questions powered by an eerily accurate AI. How do they guess so well? ...

Problem with Caching on the client side?

I want to cache data on the client. What is the best algorithm/data structure that can be employed? Case 1. The data to be stored requires extremely fast string searching capability. Case 2. The cached data set can be large. I don't want to explode the client's memory usage and also I don't want to make a network and disk access calls w...

Algorithm to find first index where strings are different?

I've got a collection of strings, and I need to know the first index where they all differ. I can think of two ways to do this: (the following pseudo code is just off the top of my head and may be heavily bug-laden) First Way: var minLength = [go through all strings finding min length]; var set = new set() for(i=0;i<minlength;i++) { ...