algorithm

Re-sort orders to improve warehouse efficiency

I am trying to optimize how orders are filled at my work. Right now, an employee just grabs the latest 16 orders(sometimes 14 or 18) and fills them. I am trying to change it so that instead of simply going by the latest list of orders, that it orders them so each batch has order in similar locations. But I can't figure out how I should...

Convert frames to NTSC Drop Frame Timecode

I'm looking for a function that converts an integer value in frames to NTSC Drop Frame Timecode (hh:mm:ss.ff). I'm using Delphi, but could be in any language. Thanks ...

Deducing item cost from totals?

This can be broken down into a simple trio of equations: a + b = 3 b + c = 5 a + c = 4 How can I best approximate the values? Note, I'll have many more such totals and variables in real applications. Particularly, I want to find if its possible to usefully approximate the cost of food by item lists and totals from grocery receipts. I ...

compare function for upper_bound / lower_bound

I want to find the first item in a sorted vector that has a field less than some value x. I need to supply a compare function that compares 'x' with the internal value in MyClass but I can't work out the function declaration. Can't I simply overload '<' but how do I do this when the args are '&MyClass' and 'float' ? float x; std::vect...

Circular lock-free buffer

I'm in the process of designing a system which connects to one or more stream of data feeds and do some analysis on the data than trigger events based on the result. In a typical multi-threaded producer/consumer setup, i will have multiple producer threads putting data into a queue, and multiple consumer threads reading the data, and the...

How to create a MEME algorithm?

if you don't know what does meme mean you can read this article readwriteweb my question is how to create a meme algorithm, I have a website which aggregated thousands of blogs posts and I want to figure the most talked about stories. see this quotation from the article above "Meme aggregation attempts to cut down on the signal t...

saving Btrees to a disk file and read it

I want to save a Btree(not sure a binary one) in a disk file. and then read it to the memory. some Level-order traversal may be a good way for a binary Btree. but if it is not a binary one. I build up the Btree from the leafnode to the rootnode in memory. I believe that I have to define some structures in the disk file and output the tre...

Efficient algorithm to randomly select items with frequency

Given an array of n word-frequency pairs: [ (w0, f0), (w1, f1), ..., (wn-1, fn-1) ] where wi is a word, fi is an integer frequencey, and the sum of the frequencies fi = m, I want to use a pseudo-random number generator (pRNG) to select p words wj0, wj1, ..., wjp-1 such that the probability of selecting any word is proportional to its ...

Finding the path with the maximum minimal weight

Hi I'm trying to work out an algorithm for finding a path across a directed graph. It's not a conventional path and I can't find any references to anything like this being done already. I want to find the path which has the maximum minimum weight. I.e. If there are two paths with weights 10->1->10 and 2->2->2 then the second path is c...

C# tree/collection algorithm

I need to fill a tree-like UI control with some items (of course in parent-child1-child2-...childN relations) and before proceeding I want to ensure that the my collection that holds the content is ordered properly as follows: Each object(in this case an instance of my Category class) from my collection (ObservableCollection that is not...

Nonrecursively generating all possible permutations of elements from two arrays

I'm trying to generate all possible equations given an String array of operators (+,-,*,/) and an String array of variables (a,b,c ...). Each equation will be composed of pairs of variables and numbers (a+ b- c/ b), except the last variable, which has no operator following it. The algorithm must generate equations of variable lengths (2 ...

Fast Collision Detection for Circle Insertion into 2D Plane

Hello all. I know there are lots of posts about collision detection generally for sprites moving about a 2D plane, but my question is slightly different. I'm inserting circles into a 2D plane. The circles have variable radii. I'm trying to optimize my method of finding a random position within the plane where I can insert a new circl...

How to compute optimal paths for traveling salesman bitonic tour?

UPDATED After more reading, the solution can be given with the following recurrence relation: (a) When i = 1 and j = 2, l(i; j) = dist(pi; pj ) (b) When i < j - 1; l(i; j) = l(i; j - 1) + dist(pj-1; pj) (c) When i = j - 1 and j > 2, min 1<=k<i (l(k; i) + dist(pk; pj )) This is now starting to make sense, except for part C. How would ...

Project Euler Problem 245

I'm onto problem 245 now but have hit some problems. I've done some work on it already but don't feel I've made any real steps towards solving it. Here's what I've got so far: We need to find n=ab with a and b positive integers. We can also assume gcd(a, b) = 1 without loss of generality and thus phi(n) = phi(ab) = phi(a)phi(b). We are...

Data structure/algorithm for variable length record storage and lookup on disk withsearch only on primary keys

I am looking for an algorithm / data structure that works well for large block based devices (eg a mechanical hard drive) which is optimised for insert, get, update and delete where searches are always done using the id of the data and where the data fields for any ID have a variable length. The B-Tree seems to be a commonly quoted stru...

How to implement this equation in Java?

Ok, this is more of a follow-up question: http://stackoverflow.com/questions/874982/how-to-compute-optimal-paths-for-traveling-salesman-bitonic-tour First of all, for the bitonic tour of the traveling salesman problem I have the following recurrence relation: (a) When i = 1 and j = 2, l(i; j) = dist(pi; pj ) (b) When i < j - 1; l(i; j)...

Interpolation algorithms when downscaling

Im trying to understand downscaling. I can see how interpolation algorithms such as bicubic and nearest neighbour can be used when when upscaling, to "fill in the blanks" between the old, known points (pixels, in case of images). But downscaling? I cant see how any interpolation technique can be used there. There are no blanks to fill! ...

Are the Donald Knuth books worth buying

As an EE turned software engineer I missed on on the computer science basics. Are the Donald Knuth "The Art of Computer Programming" books worth buying as a reference for filling in the gaps? Or as a reference in general? ...

Fastest algorithm for circle shift N sized array for M position

What is the fastest algorithm for circle shifting array for m positions? For example [3 4 5 2 3 1 4] shift m = 2 positions should be [1 4 3 4 5 2 3] Thanks a lot ...

Interview qns...Do the below without any conditional or comparison operator.

Hi All, Do the below without any conditional or comparison operator. if (Number <= 0) { Print '0'; } else { print Number; } thanks.. ...