Re: [algogeeks] Re: Adobe Strings matching Puzzle.

2010-07-28 Thread Shiv ...
Excuse the indentations, how about the following solution? O(strlen(B)). match(char * A, char *B) { char * tempA = *A; while(1) { char * tempB=*B; while(*B *B == *A) { *B++;*A++; } if(!*B) return *tempB; else { while(*B *B++ != *A) ; if(*B) continue; else return NULL; } //while(1) }//match()

Re: [algogeeks] Re: Adobe Strings matching Puzzle.

2010-07-28 Thread Shiv ...
Ignore the last post. match(char * A, char *B) { char * tempA = *A; while(1) { char * tempB=*B; while(*B *B == *A) { *B++; *A++; } if(!*B) return *tempB;

Re: [algogeeks] Re: a google question

2010-07-28 Thread manish bhatia
I guess your solution would also be proved incorrect with the following, Numbers in bold are the two arrays. 125 122 120 110 104 103 102 101 100 999897 130255 252 250 240 234 233 232 231

[algogeeks] finding repeated substrings

2010-07-28 Thread Harsha Nagesh
Hi, Given a string, I am interested in finding all repeated substrings of any length (not just the longest substring). Can anybody point me to the right algorithm/literature for this problem? My original problem is finding repeated subtrees in a tree that has nodes of different kind. My plan

Re: [algogeeks] Re: algorithm

2010-07-28 Thread janak
How about keeping heap? Have two heaps 1. max heap and 2. min heap keep them equal size all the time and shift top element from one to other when required... On Wed, Jul 28, 2010 at 7:46 AM, Gene gene.ress...@gmail.com wrote: I think you have confused the statement of this problem.  The (in

[algogeeks] On Complexity of Algorithm

2010-07-28 Thread sourav
A sorting algorithm takes 1 second to sort 1,000 items on your local machine. How long will it take to sort 10,000 items ... if you believe that the algorithm takes time roughly proportional to nlogn? [Show your calculations / logic to arive at an answer] -- You received this message because

[algogeeks] Re: On Complexity of Algorithm

2010-07-28 Thread Dave
t = C * n log n, where C is the constant of proportionality, which will depend on the base of the logarithms used. (We can use any convenient base. I'll use base 10.) 1 = C * 1000 log 1000 so C = 1/3000. Then, when n = 10,000, t = 1 * log 1 / 3000 = 4/3000 = 13.3 sec. The algorithm

[algogeeks] ALGORITHM

2010-07-28 Thread akshay
An array of unsorted numbers n is given with one no.repeated once ie n-1 distinct nos to find duplicate no. in o(n) complexity -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To

[algogeeks] Re: ALGORITHM

2010-07-28 Thread sourav
@akshay Does the array contain numbers in the range 1 to n? On Jul 28, 8:16 pm, akshay akshayrastogi2...@gmail.com wrote: An array of unsorted numbers n is given with one no.repeated once ie n-1 distinct nos to find duplicate no. in o(n) complexity -- You received this message because you

Re: [algogeeks] ALGORITHM

2010-07-28 Thread Shiv ...
What if the number are not consecutive? My approach- Put the numbers in a hash till a collision occurs. On Wed, Jul 28, 2010 at 9:21 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: Solution : 1. Find Xor of numbers from 1 to n-1. 2. Find Xor of the numbers present in the array. 3. Xor the