[algogeeks] Re: PLEASE HELP ME - Party Lamps

2011-09-16 Thread Don
There are a lot of simplifications you can make to get this problem down to a manageable size. First of all, notice that each of the four buttons inverts itsself. So if you press it twice, you are back to the initial state. The order of button pushes does not matter. Any order of the same button

[algogeeks] Re: please help

2011-07-26 Thread coder coder
in the circular array ABCDEABCCDE The answer is 6 because the circular string starting from the element A in the 6th position comes first in the dictionary formed from all the possible strings of the circular array. for ABCDEAABCCDA is 6 -- You received this message because you are subscribed

Re: [algogeeks] Re: please help

2011-07-26 Thread Ankur Khurana
i believe you are asking for rank in lexicographic rotation On Tue, Jul 26, 2011 at 11:52 PM, coder coder i.code.program...@gmail.comwrote: in the circular array ABCDEABCCDE The answer is 6 because the circular string starting from the element A in the 6th position comes first in the

Re: [algogeeks] Re: please help

2011-07-26 Thread Pratz mary
would it make a difference if it wasnt a circular array? On 26 July 2011 23:52, coder coder i.code.program...@gmail.com wrote: in the circular array ABCDEABCCDE The answer is 6 because the circular string starting from the element A in the 6th position comes first in the dictionary formed

Re: [algogeeks] Re: please help

2011-07-26 Thread ankit sambyal
int getFirstIndexInLex(char arr[],int size) { int minindex=0,i; for(i=1;isize;i++) { if(arr[i] arr[minindex]) minindex=i; else if(arr[i]==arr[minindex]) minindex=checkmin(arr,size,minindex,i); } return minindex; } int checkmin(char

[algogeeks] Re: please help

2011-07-26 Thread coder coder
yes -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at

Re: [algogeeks] Re: please help

2011-07-26 Thread coder coder
@ankit your answer is wrong for the test case ABCDEAABCCDA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: please help

2011-07-26 Thread ankit sambyal
There is a mistake in my code: In the function int checkmin(char arr[],int size,int i,int j) after the while loop in the line if(k==0) It shud be : if(k==size) instead of if(k==0) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] Re: please help

2011-07-26 Thread coder coder
ankit your solution gives answer 11 for test case ABCDEAABCCDA ie AABCDEAABCCD Isn't solution is AABCCDAABCDE ie 6 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe

Re: [algogeeks] Re: please help

2011-07-26 Thread ankit sambyal
@coder: my mistake. There is a typo in my code. the condition is : while(arr[i]==arr[j] ksize) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group,

Re: [algogeeks] Re: please help

2011-07-26 Thread coder coder
@ankit still your solution is not giving the correct result for this test case -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: please help

2011-07-26 Thread ankit sambyal
@coder : No, my solution gives the correct answer. Check it out again !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: please help

2011-07-26 Thread coder coder
the answer should be 6 correct me if i am getting the question wrong #includeiostream using namespace std; int checkmin(char arr[],int size,int i,int j) { int k=0; while(arr[i]==arr[j] ksize) { i=(i+1)%size; j=(j+1)%size; k++; } if(k==size) return i;

Re: [algogeeks] Re: please help

2011-07-26 Thread aditi garg
can u plz explain dis code? On Wed, Jul 27, 2011 at 12:37 AM, coder coder i.code.program...@gmail.comwrote: the answer should be 6 correct me if i am getting the question wrong #includeiostream using namespace std; int checkmin(char arr[],int size,int i,int j) { int k=0;

Re: [algogeeks] Re: please help

2011-07-26 Thread ankit sambyal
@coder :Got my mistake. There is a slight change in the checkmin function. Actually I was returning the modified value of i and j. Following is the correct code : #includeiostream using namespace std; int checkmin(char arr[],int size,int i,int j) { int k=0,*m=i,n=j*; while(arr[i]==arr[j]

Re: [algogeeks] Re: please help

2011-07-26 Thread coder coder
thanx bro -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this

Re: [algogeeks] Re: please help

2011-07-26 Thread SkRiPt KiDdIe
#includecmath #includecstdio #includeiostream #includestring using namespace std; #define ll long long int #define INF 0x7fff int mask(ll x,string str,ll dist) { ll re=INF,y=0,len; len=str.size(); for(int i=0;ilen;i++) if( !(x(1LLi)) || str[(i+dist)%len]re )continue;

Re: [algogeeks] Re: please help

2011-07-26 Thread SkRiPt KiDdIe
#includecmath #includecstdio #includeiostream #includestring using namespace std; #define ll long long int #define INF 0x7fff ll mask(ll x,string str,ll dist) { ll re=INF,y=0,len; len=str.size(); for(int i=0;ilen;i++) if( !(x(1LLi)) || str[(i+dist)%len]re )continue;

Re: [algogeeks] Re: please help

2011-07-26 Thread SkRiPt KiDdIe
#includecmath #includecstdio #includeiostream #includestring using namespace std; #define ll long long int #define INF 0x7fff ll mask(ll x,string str,ll dist) { ll re=INF,y=0,len; len=str.size(); for(int i=0;ilen;i++) if( !(x(1LLi)) || str[(i+dist)%len]re

[algogeeks] Re: please help me

2011-06-11 Thread siva viknesh
http://geeksforgeeks.org/ On Jun 8, 4:07 pm, coder dumca coder.du...@gmail.com wrote: I am last year  student preparing for placements can any one give some ebooks on data structure,  algo etc.  like beofre some time , some one posted a book how to crack the coding interview  that was an

[algogeeks] Re: please help me

2011-06-09 Thread coder dumca
I need some more books specialy on algo ds and puzzles On Wed, Jun 8, 2011 at 4:07 AM, coder dumca coder.du...@gmail.com wrote: I am last year student preparing for placements can any one give some ebooks on data structure, algo etc. like beofre some time , some one posted a book how to

Re: [algogeeks] Re: please help me

2011-06-09 Thread Navneet Gupta
Try placementsindia.blogspot.com , it has a good collection of problems specific to placements. On Thu, Jun 9, 2011 at 12:23 PM, coder dumca coder.du...@gmail.com wrote: I need some more books specialy on algo ds and puzzles On Wed, Jun 8, 2011 at 4:07 AM, coder dumca coder.du...@gmail.com

[algogeeks] Re: Please help in verifying the speed of this algorithm - factorizing or prime finder.

2011-04-08 Thread Don
This link has an online application which factors large numbers using the Elliptic Curve method. http://www.alpertron.com.ar/ECM.HTM Try a value like 12991627363868130524522557049357159496792541860595064869631. On my computer this application factors this number in 15 seconds. Anything relying

[algogeeks] Re: Please help in verifying the speed of this algorithm - factorizing or prime finder.

2011-04-07 Thread harish
Hi Don, I reposting my reply to you to all now.. The GNFS mentioned here is polynomial time as I got to understand from wikipedia. I claim that the above algorithm is linear time. I putting the proof here for correctness and linear time (warning its big and messy). Also this one applies to the

[algogeeks] Re: Please help in verifying the speed of this algorithm - factorizing or prime finder.

2011-04-07 Thread harish
Hi All, I got a reply at another forum; here is the link for that http://stackoverflow.com/questions/5581040/i-have-a-new-algorithm-to-find-factors-or-primes-in-linear-time-need-verificati .. Don i believe you are correct. Thanks Harish On Apr 7, 4:56 pm, harish hareeshgn...@gmail.com wrote:

[algogeeks] Re: Please help in verifying the speed of this algorithm - factorizing or prime finder.

2011-04-06 Thread Don
The General Number Field Sieve is the fastest known method of factoring large numbers, but the elliptic curve method may be faster in some cases. Either one is much faster than your method. Don On Apr 6, 12:58 pm, harish hareeshgn...@gmail.com wrote: Hi all, I have developed an algorithm to

[algogeeks] Re: Please help me!!!!

2007-06-13 Thread Phanisekhar B V
For the second question its not possible to do it in O(log n), as u need O(n) time to read the elements itself. You need to check your second question. There might be some constraints associated with the arrays. On 5/19/07, dor [EMAIL PROTECTED] wrote: 1. You can certainly do it in O(n

[algogeeks] Re: Please help me!!!!

2007-06-01 Thread Peeyush Bishnoi
A. for finding the repeated elements in an array. 1. make a loop that goes thru from first to last element. store the first array element into new array narr. compare the array element from narr with new array element of step 1. if array element from step 1 is

[algogeeks] Re: please help me solve the exercise 14.1-8 of introduction to algorithm

2007-01-23 Thread Karthik Singaram L
Hi, You can try a similar technique... Start at an arbitrary endpoint, Set the number of open chords to zero, Set the number of intersections to zero Traverse the endpoints along the circle in one direction (made possible by sorting radially) { If the endpoint is one that closes

[algogeeks] Re: please help me solve the exercise 14.1-8 of introduction to algorithm

2007-01-22 Thread Sandesh
Hi, suppose the chords are represented as (x1,y1) (x2,y2) and x1 x2 then sort the chords according to x1 - o(nlogn) then for each chords check with how many chords it intersects (consider only x values), logn for each key so another o(nlogn) repeat the procedure with replacing x by y