algorithm

Code golf: combining multiple sorted lists into a single sorted list

Implement an algorithm to merge an arbitrary number of sorted lists into one sorted list. The aim is to create the smallest working programme, in whatever language you like. For example: input: ((1, 4, 7), (2, 5, 8), (3, 6, 9)) output: (1, 2, 3, 4, 5, 6, 7, 8, 9) input: ((1, 10), (), (2, 5, 6, 7)) output: (1, 2, 5, 6, 7, 10) Note:...

Which algorithm can efficiently find a set of points within a certain distance of a path?

Given a set of points s (a set of x,y coordinates) and a path that is made up of line segments joining a set of points l, describe an efficient algorithm that can be used to find a subset of points from s that are within the specified distance d of the path l. A practical application of this may be to find a list of restaurants within 1...

(C++) Need to figure out all points within a radius using reg. 2D windows coord. system

Sorry in advance, I'm struggling a bit with how to explain this... :) Essentially, I've got a typical windows coordinate system (the Top, Left is 0,0). If anybody's familiar with the haversine query, like in SQL, it can get all points in a radius based on latitude and longitude coordinates. I need something much simpler, but my math s...

Is there a way to quickly resize a jpeg to 1/8 of its original size in .NET?

And hopefully with as little loss as possible, as I've heard the implementation put forward by a guy named Guido Vollbeding. Standard GDI+ doesn't seem to have this capability, and all I've found so far are either specs or fully-integrated tools. A lean, pluggable .NET component would be highly desirable. What are common pitfalls if it c...

Sorting values, but only if they are X more than current order

Hi, I've been searching Google (and stack overflow of course!) for a way to sort a list of integers by value, but also by an extra factor. I'm looking for some sort of algorithm to implement I suppose. So far, I have an array in Delphi 2007 that sorts the values from largest to smallest, but now I would like it to sort values that are...

Worse is better. Is there an example?

Is there a widely-used algorithm that has time complexity worse than that of another known algorithm but it is a better choice in all practical situations (worse complexity but better otherwise)? An acceptable answer might be in a form: There are algorithms A and B that have O(N**2) and O(N) time complexity correspondingly, but...

How do determine if a polygon is complex/convex/nonconvex?

From the man page for XFillPolygon · If shape is Complex, the path may self-intersect. Note that con‐ tiguous coincident points in the path are not treated as self- intersection. · If shape is Convex, for every pair of points inside the polygon, the line segment connecting them does not i...

keystroke generation

Hi, I have a scenario where i need to generate all possible keystrokes using numbers 2 to 9. The possible keystrokes should generate 2-git, 3-digit etc upto 32-digit numbers. can anybody tell me what is the best way to solve this problem. Thanks, Pdit ...

A simple example of a cache aware algorithm?

Can someone post any simple explanation of cache aware algorithms? There are lot of links available but the reading material in those sites is academic in nature and time consuming to read and comprehend. ...

How to use miniclip algorithm in a TIc-Tac-Toe game(X0) php

Hi I am working on a online TIc-Tac-Toe game using the miniclip algorithm to calculate the best move.I found few examples but i really don't understand the miniclips logic.Some example would be great. Thanks! ...

Calculate Time Remaining

What's a good algorithm for determining the remaining time for something to complete? I know how many total lines there are, and how many have completed already, how should I estimate the time remaining? ...

Word comparison algorithm

I am doing a CSV Import tool for the project I'm working on. The client needs to be able to enter the data in excel, export them as CSV and upload them to the database. For example I have this CSV record: 1, John Doe, ACME Comapny (the typo is on purpose) Of course, the companies are kept in a separate table and linked with...

Pluralize - Singularize

Is there any algorithm in c# to singularize - pluralize a word (in english) or does exist a .net library to do this (may be also in different languages)? ...

Algorithm to find two points furthest away from each other

Im looking for an algorithm to be used in a racing game Im making. The map/level/track is randomly generated so I need to find two locations, start and goal, that makes use of the most of the map. The algorithm is to work inside a two dimensional space From each point, one can only traverse to the next point in four directions; up, dow...

Best Algorithm to find the edges (polygon) of vertices

I have a large array of vertices, some of them are edges, some are redundant (inside the shape) and I want to remove those. The simplest algorithm I could think of is checking one by one if they hit the shape formed by the others. But it should be a very slow algorithm. I thought about picking one from the edge (the one farthest from o...

constructing the contour of a 2d figure(in particular a triangulation)

Hi, How would I go about constructing the contour of 2d figure which is formed of only triangles and it can have holes and the external contour can be concave/convex and the holes can also be concave/convex. From what I'm reading over here it seems that It's exactly the inverse of the triangulation problem. Do you know any articles tre...

PHP Arrays - Remove duplicates ( Time complexity )

Okay this is not a question of "how to get all uniques" or "How to remove duplicates from my array in php". This is a question about the time complexity. I figured that the array_unique is somewhat O(n^2 - n) and here's my implementation: function array_unique2($array) { $to_return = array(); $current_index = 0; for ( $i =...

Efficient evaluation of hypergeometric functions

Does anyone have experience with algorithms for evaluating hypergeometric functions? I would be interested in general references, but I'll describe my particular problem in case someone has dealt with it. My specific problem is evaluating a function of the form 3F2(a, b, 1; c, d; 1) where a, b, c, and d are all positive reals and c+d >...

Algorithm for modeling expanding gases on a 2D grid

I have a simple program, at it's heart is a two dimensional array of floats, supposedly representing gas concentrations, I have been trying to come up with a simple algorithm that will model the gas expanding outwards, like a cloud, eventually ending up with the same concentration of the gas everywhere across the grid. For example a giv...

What is the easiest algorithm to find the day of week of day zero of a given year?

I am trying to figure out what the day of the week of day zero (January 1st) of a given year. So far I have looked at the Wikipedia page 'Calculating the day of the week' but I was wondering if there is an easiest algorithm if you're just trying to find day zero. ...