algorithm

How can I tell if a point is nearby a certain line ?

Hi there, I asked "How can I tell if a point belongs to a certain line?" before and I found a suitable answer so thank you very much. Now, I would like to know how to tell if a certain point is close to my line. ...

How does a non-forking web server work?

Non-forking (aka single-threaded or select()-based) webservers like lighttpd or nginx are gaining in popularity more and more. While there is a multitude of documents explaining forking servers (at various levels of detail), documentation for non-forking servers is sparse. I am looking for a bird eyes view of how a non-forking web ser...

sorting algorithm where pairwise-comparison can return more information than -1, 0, +1

Most sort algorithms rely on a pairwise-comparison the determines whether A < B, A = B or A > B. I'm looking for algorithms (and for bonus points, code in Python) that take advantage of a pairwise-comparison function that can distinguish a lot less from a little less or a lot more from a little more. So perhaps instead of returning {-1,...

How can I transform a string into an abbreviated form?

I want to fit strings into a specific width. Example, "Hello world" -> "...world", "Hello...", "He...rld". Do you know where I can find code for that? It's a neat trick, very useful for representing information, and I'd like to add it in my applications (of course). Edit: Sorry, I forgot to mention the Font part. Not just for fixed widt...

which sorting algorithms give near / approximate sort sooner?

Which sorting algorithms produce intermediate orderings which are good approximations? By "good approximation" I mean according to metrics such as Kendall's tau and Spearman's footrule for determining how "far" an ordered list is from another (in this case, the exact sort) The particular application I have in mind is where humans are d...

Mahjong-solitaire solver algorithm, which needs a speed-up

Dears, I'm developing a Mahjong-solitaire solver and so far, I'm doing pretty good. However, it is not so fast as I would like it to be so I'm asking for any additional optimization techniques you guys might know of. All the tiles are known from the layouts, but the solution isn't. At the moment, I have few rules which guarantee safe r...

Information on L-Systems

Hey Stack Overflow folks, I am about to start a project for university to build a procedural city for a pre existing project. I was wondering if any of you have had any experience coding L-Systems before and know a good place for me to start out. I have done a bit of work before using procedural methods and Perlin Noise and fBm so i get ...

Database connection pooling datastructure

I would like to develop database connection pooling. Could anyone please tell me about which data structure need to use to maintain the pool ? ...

Keeping of track of the states of object - SOS

Hi the wise folks at SO. This is an SOS. I'm in a deep trouble. In my web application there is an object (Say it is a request for something). User submits his/her request. After this it comes to the people who can approve/disapprove that request. During the period from submission to approval/disapproval many actions can be taken on the ...

Ordering coordinates problem (QUESTION FROZEN)

Thanks for all your help on this question but your answers and thoughts have made us think about our problem even more and we cannot agree on what the problem criteria shoudld be - dont put any more answers for now - but watch this space and we will get back to you...Cheers Have been scatching my head about this - and I reckon it's simp...

What algorithms do "the big ones" use to cluster news?

I want to cluster texts for a news website. At the moment I use this algorithm to find the related articles. But I found out that PHP's similar_text() gives very good results, too. What sort of algorithms do "the big ones", Google News, Topix, Techmeme, Wikio, Megite etc., use? Of course, you don't know exactly how the algorithms work....

Categorizing input data into sets based on attribute.

Greetings! I feel like this problem is related to the bin packing problem, as well as potentially to the set partitioning problem... I just want to bounce this off of someone before I head down the path too deeply. I have input data (in a datafile) as follows: entry_one 55 entry_two 56 entry_three 61 entry_four 62 entry_five 62 entry_...

Do you write your algorithm out in pseudocode before coding?

So I know of a few people that actually write their algorithms out in plain English (pseudocode) before coding. I'd never done this before, but now that I think about it, it kind of makes sense for organizing complicated algorithms. Do you do this? Does it help? If not, what do you do (if anything) to organize your program before you wri...

A* heuristic: Shortest path passing once in multiple points

I'm trying to come up with a good and fast heuristic for a clear-map pacman game. My heuristic is trying to calculate the smallest distance possible that the pacman needs to travel to go to every points with food on the map. My current algorithm is basicly Prim's MST which gets me a O(n logn) running time, but doen't account for situati...

Mapping two integers to one, in a unique and deterministic way

Imagine two positive integers A and B. I want to combine these two into a single integer C. There can be no other integers D and E which combine to C. So combining them with the addition operator doesn't work. Eg 30 + 10 = 40 = 40 + 0 = 39 + 1 Neither does concatination work. Eg "31" + "2" = 312 = "3" + "12" This combination operation...

Is there an effient way of determining whether a leaf node is reachable from another arbitrary node in a Directed Acyclic Graph?

Wikipedia: Directed Acyclic Graph Not sure if leaf node is still proper terminology since it's not really a tree (each node can have multiple children and also multiple parents) and also I'm actually trying to find all the root nodes (which is really just a matter of semantics, if you reverse the direction of all the edges it'd they'd b...

What is a good datastructure to keep cumulative values in ?

I am looking for an idea, concept or proven datastructure that would be very efficient when accessing a collection that keeps cumulative values. Example may shed more light on my need: I have a list of values (2,3,5). This list when looking at the cumulative values would be (2,5,10). I will now add 1 at the start of the list and get ...

Equidistant points in a line segment

Let assume you have two points (a , b) in a two dimensional plane. Given the two points, what is the best way to find the maximum points on the line segment that are equidistant from each point closest to it with a minimal distant apart. Any help will be greatly appreciated. Thanks. I use c#, but examples in any language would be hel...

Algorithm to determine indices i..j of array A containing all the elements of another array B

I came across this question on an interview questions thread. Here is the question: Given two integer arrays A [1..n] and B[1..m], find the smallest window in A that contains all elements of B. In other words, find a pair < i , j > such that A[i..j] contains B[1..m]. If A doesn't contain all the elements of B, then i,...

Helper library for distributed algorithms programming?

When you code a distributed algorithm, do you use any library to model abstract things like processor, register, message, link, etc.? Is there any library that does that? I'm thinking about e.g. self-stabilizing algorithms, like self-stabilizing minimum spanning-tree algorithms. ...