algorithm

Implementing Excel and VB's IRR function

I need to port the IRR function found in Excel and VB to ActionScript. Excel IRR formula Any idea how to find the "source" to such functions? does anyone have this implemented in some other c-like language? ...

How to draw a Perspective-Correct Grid in 2D

I have an application that defines a real world rectangle on top of an image/photograph, of course in 2D it may not be a rectangle because you are looking at it from an angle. The problem is, say that the rectangle needs to have grid lines drawn on it, for example if it is 3x5 so I need to draw 2 lines from side 1 to side 3, and 4 lines...

Fast text editor find

Does anyone know how text editors/programmers editors are able to do such fast searches on very large text files. Are they indexing on load, at the start of the find or some other clever technique? I desperately need a faster implementation of what I have which is a desperately slow walk from top to bottom of the text. Any ideas are r...

Finding patterns in source code

If I wanted to learn about pattern recognition in general what would be a good place to start (recommend a book)? Also, does anybody have any experience/knowledge on how to go about applying these algorithms to find abstraction patterns in programs? (repeated code, chunks of code that do the same thing, but in slightly different ways, e...

Algorithm Speed Order of

Hi folks, Sometimes I get totally fooled trying to estimate an algorithm's speed with the O(x) notation, I mean, I can really point out when the order is O(n) or O(mxn), but for those that are O(lg(n)) or O(C(power n)) I think that I am missing something there... So, what are your tips and tricks for an easy estimate with a fast overloo...

Analyzing, categorizing and indexing metadata

I have a large (~2.5M records) data base of image metadata. Each record represents an image and has a unique ID, a description field, a comma-separated list of keywords (say 20-30 keywords per image), and some other fields. There's no real database schema, and I have no way of knowing which keywords exists in the database without iterati...

What algorithm can I use to determine points within a semi-circle?

I have a list of two-dimensional points and I want to obtain which of them fall within a semi-circle. Originally, the target shape was a rectangle aligned with the x and y axis. So the current algorithm sorts the pairs by their X coord and binary searches to the first one that could fall within the rectangle. Then it iterates over e...

Non-exponential solution to maze problem?

Given a n*n-sized multi-headed acyclic graph where each node has at most three children and three parents, is there an non-exponential algorithm to identify whether a n-length path exists where no two nodes share the same value, and every value of a set is accounted for? Basically, I have an n*n maze where each space has a random value ...

Java simple String diff util

Hi, I'm looking for a simple java lib/src to highlight differences between two Strings, case-sensitive. A html output would be great, but I would be happy to get the indexes of the diffs, something like: diff("abcd","aacd") > [2,2] diff("maniac", "brainiac") > ["man",brain"] or [0,3] or something like that The idea is to higlight ty...

Resources about building an RDBMS

I'm looking at implementing an RDBMS. Are there any good resources out there about how a database works internally, and the kinds of things I'd need to know when starting out to build my own? (Please no comments about whether it's a practical idea or not - just imagine it's for a hobby project or something). Again - interested in the ...

How to implement an offline reader writer lock

Some context for the question All objects in this question are persistent. All requests will be from a Silverlight client talking to an app server via a binary protocol (Hessian) and not WCF. Each user will have a session key (not an ASP.NET session) which will be a string, integer, or GUID (undecided so far). Some objects might ta...

Looking for a Hash Function /Ordered Int/ to /Shuffled Int/

I am looking for constant time algorithm can change an ordered integer index value into a random hash index. It would nice if it is reversible. I need that hash key is unique for each index. I know that this could be done with a table look up in a large file. I.E. create an ordered set of all ints and then shuffle them randomly and write...

Compute the area of intersection between a circle and a triangle?

How does one compute the area of intersection between a triangle (specified as three (X,Y) pairs) and a circle (X,Y,R)? I've done some searching to no avail. This is for work, not school. :) It would look something like this in C#: struct { PointF vert[3]; } Triangle; struct { PointF center; float radius; } Circle; // returns the a...

Where is binary search used in practice?

Every programmer is taught that binary search is a good, fast way to search an ordered list of data. There are many toy textbook examples of using binary search, but what about in real programming: where is binary search actually used in real-life programs? ...

How does Firefox's 'awesome' bar match strings?

The question is how the string matching is done to find matching entries by the firefox 3 url bar. Substring matching on every entry might be slow. What algorithm can be used to match at any location in a fast way? ...

Algorithm to find an optimum number of rummy-style sets?

I'm developing a card game that uses rummy-style sets of three cards. From a random selection of cards, I need the algorithm to pick out which cards would get me the highest number of sets. By "rummy-style sets of three" I mean: All three cards have the same value, like three Jacks. OR All three cards are of the same suit and sequenti...

Can any algorithmic problem be solved in a purely functional way?

I've been contemplating programming language designs, and from the definition of Declarative Programming on Wikipedia: This is in contrast from imperative programming, which requires a detailed description of the algorithm to be run. and further down: ... Any style of programming that is not imperative. ... It then goes on to...

Are there any software guarantees in critical systems?

Are there systems or is there software out there that is developed with a proof of correctness to back it up? Or are all critical systems developed merely with an aggressive code review and test cycle? ...

Is there any algorithm for search an element in sorted array with complexity less than log2(n)

i have coded an algorithm for search in sorted array with complexity log2(n)/5 .Is it useful? ...

Algorithm to compute a Voronoi diagram on a sphere?

Hi, I'm looking for a simple (if exists) algorithm to find the Voronoi diagram for a set of points on the surface of a sphere. Source code would be great. I'm a Delphi man (yes, I know...), but I eat C-code too. TIA Steven ...