algorithm

How to create value generator ala hex in c#

Hi everyone. I would like to create unique value generator that would work like this: I have 8 places for chars and it would create values like this: 00000001 . 0000000z . 00000010 . 0000001z etc. so it would create values from 00000001 to zzzzzzzz. I have only 8 places because this is the size of the field in the database and I can'...

Help me with my backprop implementation in Python

EDIT2: New training set... Inputs: [ [0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0], [0.0, 4.0], [1.0, 0.0], [1.0, 1.0], [1.0, 2.0], [1.0, 3.0], [1.0, 4.0], [2.0, 0.0], [2.0, 1.0], [2.0, 2.0], [2.0, 3.0], [2.0, 4.0], [3.0, 0.0], [3.0, 1.0], [3.0, 2.0], [3.0, 3.0], [3.0, 4.0], [4.0, 0.0], [4.0,...

What does this definition of contiguous subsequences mean?

I don't understand the following definition of a contiguous subsequence: A contiguous subsequence of a list S is a subsequence made up of consecutive elements of S. If S is {5, 15, -30, 10, -5, 40, 10} then 15, -30, 10 is a contiguous subsequence. What makes 15, -30, 10 a contiguous subsequence? ...

Is my programming logic correct here?

const char IsPressed = 1; // 1 const char WasHeldDown = 2; // 10 const char IsFirstPress = 4; // 100 char* keystates[256]; Class::CalculateKeyStates() { for(int i = 0; i < 256; ++i) { if(this->IsDown(i)) { keystates[i] |= IsPressed; // turn on if(keystates[i] & WasHeldDown) { ...

What are some of the applications of Order Statistics Algorithms?

I am watching the MIT lectures and Eric Demaine says that they discussed some of the applications of Order Statistics Algorithms. I was wondering if the SO community would help me figure out some of the applications of the selection algorithms. ...

Advice on how to improve a current fuzzy search implementation.

Hello. I'm currently working on implementing a fuzzy search for a terminology web service and I'm looking for suggestions on how I might improve the current implementation. It's too much code to share, but I think an explanation might suffice to prompt thoughtful suggestions. I realize it's a lot to read but I'd appreciate any help. Fi...

Find out which combinations of numbers in a set add up to a given total

I've been tasked with helping some accountants solve a common problem they have - given a list of transactions and a total deposit, which transactions are part of the deposit? For example, say I have this list of numbers: 1.00 2.50 3.75 8.00 And I know that my total deposit is 10.50, I can easily see that it's made up of the 8.00 and ...

What is an efficient algorithm for extracting bags from lists of pairs?

I have a list of pairs of objects. Objects can appear in the pair in either order. What is the most efficient algorithm (and implementation?) to find all bags (ie sets with duplicates permitted) of pairs between the same objects. For my purpose the object references can be assumed to be pointers, or names or some similar convenient, shor...

Async Request-Response Algorithm with response time limit

Hi, I am writing a Message Handler for an ebXML message passing application. The message follow the Request-Response Pattern. The process is straightforward: The Sender sends a message, the Receiver receives the message and sends back a response. So far so good. On receipt of a message, the Receiver has a set Time To Respond (TTR) t...

finding pythagorean triples (a,b,c) with a <=200

Hi All In my previous post on this subject i have made little progress (not blaming anyone except myself!) so i'll try to approach my problem statement differently. how do i go about writing the algorithm to generate a list of primitive triples? all i have to start with is: a) the basic theorem: a^2 + b^2 = c^2 b) the fact that the ...

Get Smallest Difference between Adjacent Array Elements in a Sorted List

Hi, I have a sorted list of ratios, and I need to find a "bin size" that is small enough so that none of them overlap. To put it shortly, I need to do what the title says. If you want a little background, read on. I am working on a graphical experiment that deals with ratios and the ability of the eye to distinguish between these ratios...

Is there an algorithm for computing permutation of distances?

This is related to travelling salesman problem. First all permutations need to be generated and then the destination (same as origin) attached. I.e.: 1) abcd abdc .... 2) abcda abdca ....a I have all the distances and only need an algorithm to sum them up. I wonder if there is an algorithm (C preferable) I can use for this or if there ...

Longest increasing subsequence.

Given an input sequence, what is the best way to find the longest (not necessarily continuous) non-decreasing subsequence. 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 # sequence 1, 9, 13, 15 # non-decreasing subsequence 0, 2, 6, 9, 13, 15 # longest non-deceasing subsequence (not unique) I'm looking for the best algorithm. I...

Need for both Ciphering and Integrity ?

Why do some scenarios require both ciphering and integrity whereas some scenarios require only ciphering ? What are the factors that decide this in the case of networking domain ? ...

Algorithm to process jobs with same priority

Hi Guys, I am solving exercise problems from a book called Algorithms by Papadimitrou and Vazirani. The following is the question: A server has n customers waiting to be served. The service time required by each customer is known in advance: it is ti minutes for customer i. So if, for example, the customers are served in order of incr...

how do I balance my binary tree

Hi, I already have a working binary tree database. Unfortunately, it needs to have the ability to balance itself. I don't want to rewrite the whole thing, I just want to include a function that will balance the tree. Any algorithms or ideas? ...

Determine the Scale Factor in Maps

Given only the set of coordinates, is there a way to find the scale factor being used? It will then be used to compute the distances between the coordinates. Let's consider this: On a map scale: (This is the only given) pointA(33.511615, -86.778809) pointB(34.398558, -87.669116) On a real world scale: Distance between the 2 poi...

Creative sorting algorithm?

I just wanted to know if there are any sorting algorithms that are as interesting as Bogosort to sort a pack of cards. Use your creativity. For a change efficiency ain't important but being creative is :) ...

What is the best approach of querying based on Geo parameter

I have a table which contains Geo-Based information. (latitude and longitude) i would like users to input their Latitude and Longitude value(e.g current location), then query returns the records ordered by the distance between "user inputed spot" and "record position". any suggestions or web link would be appreciated. thank you all in...

Partial string matching algorithms

Good morning, Does anyone know about efficient algorithms for partial string matching? For example, given the two strings "woods" and "woodes", the algorithm could/should possibly return "wood+s", or " | e". Thank you very much. ...