algorithm

Fuzzy/approximate checking of solutions from algorithms

We have people who run code for simulations, testing etc. on some supercomputers that we have. What would be nice is, if as part of a build process we can check that not only that the code compiles but that the ouput matches some pattern which will indicate we are getting meaningful results. i.e. the researcher may know that the value o...

How to reverse a number as an integer and not as a string?

I came across a question "How can one reverse a number as an integer and not as a string?" Could anyone please help me to find out the answer. ...

How to represent relationship between two items in DB?

Hello, me and my colleagues are developing a website with similar idea as Stackoverflow, but for submitting tasks (and for internal use). This morning we talked about tagging tasks and couldn't really figure which option would be the fastest one, or if we aren't missing something. Let's imagine table with tags, which would dynamically ...

Automatically convert CSS file to be used on dark backgrounds

I have about 200 CSS files like this: /** * GeSHi Dynamically Generated Stylesheet * -------------------------------------- * Dynamically generated stylesheet for bnf * CSS class: , CSS id: * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) * --------------------...

Random simple connected graph generation with given sparseness

I'm trying to find an efficient algorithm to generate a simple connected graph with given sparseness. Something like: Input: N - size of generated graph S - sparseness (numer of edges actually; from N-1 to N(N-1)/2) Output: simple connected graph G(v,e) with N vertices and S edges ...

Parse bignum into list of 16-bit integers

Hello, I have to implement some bignum arithmetics. The number has to be split into a list of 16 bit integers. That is not the problem. The problem is to parse a string into this notation. If it would be a single integer, i would go through the string backwards, get the number out of the char and would add <number>*10^stringposition. (...

Expression to calculate a field within a loop

I basically have a few variables 0 < na < 250 0 < max <= 16 nb = (na + max - 1) / max n has the following characterstics 0 <= i < nb - 1 => n = max i = nb - 1 => n = na - i * max Is there an easy way to do this without the ternary operator? for (i = 0; i<nb;i++) { n = ((i + 1) * max > na ? na - (i * max) : max); } Examples...

Problem with implementing successive approximation algorithm in C++ with Visual Studio 2008

I'm trying to implement an algorithm we did in numerical methods class. I have an identical procedure written in Maple and it works fine. I can't understand why it isn't working in C++. Any help or tips would be appreciated; thanks in advance. #include "stdafx.h" #include "math.h" #include <iostream> using namespace std; double absv...

Short, Java implementation of a suffix tree and usage?

I'm looking for a short, simple suffix tree building/usage algorithm in Java. The best I've found so far lies withing the Semantic Discovery Toolkit, but the implementation is several thousand lines long and spans several classes. Ideally, the implementation would be as short as possible and span no more than a few hundred lines. Does a...

Standard Pattern for Iterating Over Loop and Printing Start and End Tags

Hello all, This is a problem I have run into before and I have yet to find an elegant solution, so I thought I would ask for SO's help. I am iterating through an array and printing off some information from that array and having trouble figuring out how to print my start and end <div> tags. Below is an example table and the desired out...

How to extend a binary search iterator to consume multiple targets

I have a function, binary_range_search, that is called like so: my $brs_iterator = binary_range_search( target => $range, # eg. [1, 200] search => $ranges # eg. [ {start => 1, end => 1000}, ); # {start => 500, end => 1500} ] brs_iterator->() will ...

Minimum area quadrilateral algorithm

There are a few algorithms around for finding the minimal bounding rectangle containing a given (convex) polygon. Does anybody know about an algorithm for finding the minimal-area bounding quadrilateral (any quadrilateral, not just rectangles)? I've searched the internet for several hours now, but while I found a few theoretical papers...

Which is the best algorithm to "Estimate and Visulize 2d skeleton using Opencv" from the drawn contour

Which is the best algorithm to "Estimate and Visulize 2d skeleton using Opencv" from the drawn contour please suggest? any code or document or links are highly appriciated ...

Project Euler - Problem 272 in C#

I am have difficulties solving problem 272 of Project Euler, which has the following statement. For a positive number n, define C(n) as the number of the integers x, for which 1 < x < n and x^3 = 1 mod n. When n=91, there are 8 possible values for x, namely : 9, 16, 22, 29, 53, 74, 79, 81. Thus, C(91)=8. Find the s...

"... algorithm follows at most lg N pointers to determine..." What does lg stand for?

In the statement "The weighted quick-union algorithm follows at most lg N pointers to determine whether two of N objects are connected" what does lg stand for? ...

How to determine a point in a triangle?

Hi all Is there an easy way to determine if a point inside a triangle? It's 2D not 3D. Best Regards, ...

How to process Sound with Java?

Hey, i have to implement the LPC (linear predictive coding) Algorithm with Java and quiet frankly don't have a clue where to start. Could someone please point me into a right direction.. I can't. of course, use already implemented algorithms from the java sound api (if its provides a solution). thanks for you help fabian ...

need suggestions about content filtering project

i'm thinking of designing and implementing a content filtering software as my graduation project. i want it to be a user contributed software. i mean, users can also add/categorize websites. it should be also a web project and extensions for browsers like chrome, firefox, ie.. my question is which programming language do you suggest fo...

Algorithm For Flight Schedules

I have a list of all direct flights. From this I want to get flights from A to B with connections. What will be a suitable algorithm or data structure for this problem? Thanks. ...

Group detection in data sets

Assume a group of data points, such as one plotted here (this graph isn't specific to my problem, but just used as a suitable example): Inspecting the scatter graph visually, it's fairly obvious the data points form two 'groups', with some random points that do not obviously belong to either. I'm looking for an algorithm, that would ...