algorithm

Permutation for numbers in C

Hi programming masses, I'm trying to write a C function to list all permutations of a set of numbers, in groups of five, including repeat numbers: 15-11-49-43-5 2-30-34-6-11 So it's easy enough to write a function to grab all permutations of a number set and throw them out, but mapped to a certain group size, i'm somewhat stuck.. T...

How to convert linear search to binary search?

- This is my find() method using Binary Search algorithm: It works just as you would expect it to. No problems at all. public int find(long searchKey) { int lowerBound = 0; int upperBound = nElems - 1; int currentIndex; while(true) { currentIndex = (lowerBound + upperBound) / 2; if(a[currentIndex] == searchKey) retu...

how to crack the DES encryption algorithm....

How to break the DES encryption algorithm....using which programming language, it is most efficient. ...

Calculating similarity between drawn lines

I need an algorithm to calculate, numerically, the degree of similarity between two drawn lines. The lines are drawn using a mouse, and are stored as a set of cartesian coordinates before being filtered and smoothed using separate algorithms. For example, within the following diagram: Lines A and B are clearly similar, but B and C are...

Real world applications of Binary heaps and Fibonacci Heaps

What are the real world applications of Fibonacci heaps and binary heaps? It'd be great if you could share some instance when you used it to solve a problem. EDITED: Added binary heaps also. Curious to know. ...

How to formulate such problem mathematicaly? (line continuation search)

I have an array of "lines" each defined by 2 points. I am working with only the line segments lying between those points. I need to search lines that could continue one another (relative to some angle) and lie on the same line (with some offset) I mean I had something like 3 lines I solved some mathematical problem (formulation of wh...

What are good algorithms for detecting abnormality?

Background Here is the problem: A black box outputs a new number each day. Those numbers have been recorded for a period of time. Detect when a new number from the black box falls outside the pattern of numbers established over the time period. The numbers are integers, and the time period is a year. Question What algorithm will i...

Does anyone know what google news uses for their clustering algorithm?

curious if anyone has insight into what algorithm google news uses to group like stories together? k-means? or something custom? ...

How to balance the number of items across multiple columns

I need to find out a method to determine how many items should appear per column in a multiple column list to achieve the most visual balance. Here are my criteria: The list should only be split into multiple columns if the item count is greater than 10. If multiple columns are required, they should contain no less than 5 (except for ...

Using "unique()" on a vector of vectors in C++

I hope this is not a duplicate question, but if it is, feel free to point me in the right direction. I have a vector<vector<int> >. Is it possible to use unique() on this? Something like: vector<vector<int> > myvec; //blah blah do something to myvec vector<vector<int> >::interator it = unique(myvec.begin(), myvec.end()); Would the r...

Deciding weights for the parameters (similar to Google pagerank)

Hi, I crawled some blogs for my project and extracted a few features, like length of the document, in links, out links. Each of these blogs talks about some specific subject and there can be numerous articles on each subject, and I need to decide at most one or two important blogs for each subject. How can I assign weights to these feat...

Worker Scheduling Algorithm

The Problem Here's the essence of the problem I want to solve. We have workers taking care of children in a nursery for set times during the weekend. There's 16 different slots to fill in one weekend. So for a 4-week month there's 64 slots to fill. We have at max 30 nursery workers (though we need much more. anybody like kids?). EDIT: ...

How to find missing values in a sequence with PHP?

Hi, Suppose you have an array "value => timestamp". The values are increasing with the time but they can be reset at any moment. For example : $array = array( 1 => 6000, 2 => 7000, 3 => 8000, 7 => 9000, 8 => 10000, 9 => 11000, 55 => 1000, 56 => 2000, 57 => 3000, 59 => 4000, 60 => 5000, ); I would like to retrieve all the missing val...

Correctness of linear search

how can you prove the correctness of linear search by using the standard 3 properties which are initialization, maintenance, termination. ...

Checking whether a number is positive or negative using bitwise operators

I can check whether a number is odd/even using bitwise operators. Can I check whether a number is positive/zero/negative without using any conditional statements/operators like if/ternary etc. Can the same be done using bitwise operators and some trick in C or in C++? ...

Java: For loop and If algorithm

Hello, I've this question from an assignment to create a Store which rent out books, using a Store.java and Book.java. I've finished this assignment, but I'm curious for better algorithm to a specific part. -- Book.java public class Book { private String name; Book(String name) this.name = name; public String g...

How can I use an audio-resampler to resample IF signals

There are a lot of audio-resampling libraries available. My favorite in Secret Rabbit Code. Audio resamplers keep the correct frequency of the resampled signals, so a 4KHz sine in the source, will remain a 4KHz sine in the destination. This time, however, I need to resample a sampled IF/RF signal. The sampled signal contains data orig...

Fast Algorithm for computing percentiles to remove outliers

I have a program that needs to repeatedly compute the approximate percentile (order statistic) of a dataset in order to remove outliers before further processing. I'm currently doing so by sorting the array of values and picking the appropriate element; this is doable, but it's a noticable blip on the profiles despite being a fairly min...

DSP - Converting a sampled signal from real samples to complex samples and vice versa

How can I convert baseband sampled signal from real-valued samples to complex-valued samples (real,imaginary) and vice-versa. My samples are integers, and I'm looking for a fast (but accurate) conversion algorithms. A C++ sample code (real, not complex ;-) would be more than welcome. Edit: IPP code will be much welcome. Edit: I'm loo...

Organization chart algorithm...

Does anyone have a line on an algorithm to place boxes in an organizational chart? Any language is fine. ...