algorithm

Do you have genetic algorithm in production?

Is it good idea to use genetic algorithm in production? If you are using it: In what case? What pros for selecting subj? Can you easily add changes to algorithm? ...

Find recurrence relation of this algorithm?

Assuming n=B-A+1, I need to derive the recurrence relation of this algorithm: void recurringalgorithm(int *a, int A, int B){ if (A == B){ for (int j=0;j<B;j++){ cout<<a[j]; } cout<<endl; return; } for (int i=A;i<B;i++){ dosomething(a[A],a[i]); recurringalgorithm(a,A+1,B); dosomething(a[A],a[i]);...

php email confirm code algo ?

Hi, I saw a 'confirm_code' column in a db table, and property of the column is varchar(100), can you guys give me idea of a nice algo for a confirmation code ? Basically, it should consist of a random characters. The simplest things in my mind is just encrypting a string through md5 or sha1 but it won't fit because of the current colum...

Calculating powers (e.g. 2^11) quickly

Possible Duplicate: The most efficient way to implement an integer based power function pow(int, int) How can I calculate powers with better runtime? E.g. 2^13. I remember seeing somewhere that it has something to do with the following calculation: 2^13 = 2^8 * 2^4 * 2^1 But I can't see how calculating each component o...

what does openframe works mean(ofFill(),ofRec()...etc) any similar function can i find in opencv

what does openframe works mean(ofFill(),ofRec()...etc) any similar function can i find in opencv ...

What are the real-world applications of huffman coding?

I am told that Huffman coding is used as loseless data compression algorithm but also am told that real data compress software do not employ huffman coding,cause if the keys are not distributed decentralized enough,the compressed file could be even larger than the orignal file. This leave me wondering are there any real-world applicatio...

Find SmallestInt : Smallest integer greater than or equal to n that contains exactly k distinct digits(given values of n and k)

Hi guys, I found this on the internet. It looks good an interview question. I guess I got the working correct but programatically I haven't tried it. SmallestInt You are given an integer n. Return the smallest integer greater than or equal to n that contains exactly k distinct digits in decimal notation. Definition ...

How can I reduce the number of annotations on a map?

I'm coding a map view with around 900 annotations. Having this many annotations on a map make the performance suffer, so I'd like to reduce it to about 300 at a time. The annotations are representing shops in a country, so they tend to cluster a lot around major cities, then in small groups of 2 or 3 in smaller towns. I want to reduce th...

Map from integer ranges to arbitrary single integers

Working in C++ in a Linux environment, I have a situation where a number of integer ranges are defined, and integer inputs map to different arbitrary integers based on which range they fall into. None of the ranges overlap, and they aren't always contiguous. The "simplest" way to solve this problem is with a bunch of if-statements fo...

Repeat while changing... stop once change no longer occurs i.e. stabilise value.

I was wondering if there is a nice pattern or better yet a specific function which applies a function until there is no longer a change in it's result. url = "http://www.zzz.com/yyy/lt%255B1%255D.jpg" unescaped = unescape(url) while unescaped != url do url = unescaped unescaped = unescape(unescaped) end Although the code above is ...

Looking for "Domino combination" algorithm

Hello, I'm going to complete my apprenticeship as coder and i got a nice j2me project to work on. But i have to admit that i'm not that good with mathematical algorithms as i'd like to be. My problem is to create all possible "domino pairs" from a given set of values. For example: The possible values go from 0 to 6. Now imagine some ...

Finding if two elements in a pre-sorted array sum to equal a certain value

I'm working on a homework problem and I'm having some difficulties creating a O(n*logn) solution. I need to write a function that takes a pre-sorted array and a value to search for. I then need to find if any two elements of the array sum to equal that value. I need to create both O(n) and O(n*logn) algorithms for this. The O(n) w...

Algorithm to transform one word to another through valid words

I came across this variation of edit-distance problem: Design an algorithm which transforms a source word to a target word. for example: from head to tail, in each step, you just can replace one character, and the word must be valid. You'll be given a dictionary. It clearly is a variation of the edit distance problem, but in edit dista...

Help in quicksort algorithm program in java

Hi, I'm trying to implement QuickSort algorithm program in Java, but I'm getting incorrect answer. public class QuickSort{ public static void main(String[] args){ int arr[]={12,34,22,64,34,33,23,64,33}; int i=0; int j=arr.length; while(i<j){ i=quickSort(arr,i,i+1,j-1); } ...

Cheapest path algorithm

I've learnt a dynamic programming algorithm to find the "cheapest" path from A to B. Each sub path has an associated cost. Each corner is calculated using D(i,j).value = min( (D(i-1,j).value + D(i,j).x), (D(i,j-1).value + D(i,j).y)) Where x and y are the costs of the path on the left of the node and below the node. I'm now having trou...

How do I search a two dimensional array in any direction

I'm writing a word search puzzle in C# and I would like to be able to search the two dimensional array of characters for the words in an elegant manner. The basic searches left to right, top to bottom etc, are not to difficult to write, however things start getting a little verbose when searching diagonally accross the array. I've got...

string matching algorithms used by lucene

i want to know the string matching algorithms used by Apache Lucene. i have been going through the index file format used by lucene given here. it seems that lucene stores all words occurring in the text as is with their frequency of occurrence in each document. but as far as i know that for efficient string matching it would need to pre...

Mnemonic Password Generation Algorithm for QWERTY Keyboards

I've a "mnemonic" password generation function that goes something like this: function Mnemonic($mnemonic) { $result = null; $charset = array(str_split('aeiou', 1), str_split('bcdfghjklmnpqrstvwxyz', 1)); for ($i = 1; $i <= $mnemonic; $i++) { $result .= $charset[$i % 2][array_rand($charset[$i % 2])]; } ...

Algorithm for finding intervals inside an array

Hello, I have a list which contains n intervals [0,1] each interval looks like [a(i),b(i)] 0<=a(i)<b(i)<=1 , i = 1...n I need to find an efficient algo determining for each of the n intervals if it's contained inside other intervals. I tried many option but i can only find one in O(n^2) Any suggestions ? ...

Making change recursively: How do I modify my algorithm to print all combinations?

I have an algorithm that recursively makes change in the following manner: public static int makeChange(int amount, int currentCoin) { //if amount = zero, we are at the bottom of a successful recursion if (amount == 0){ //return 1 to add this successful solution return 1; ...