[algogeeks] Re: I want improve my algorithm??

2010-09-10 Thread soundar
www.spoj.pl www.topcoder.com/tc www.codechef.com Solve problems from these sites.. -- 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 unsubscribe from this group, send

[algogeeks] Re: Explain

2010-09-10 Thread praveen
After preprocessing Where ever there is 'A' in your program, it is replaced by 'B' Where ever there is 'B' in your program, it is replaced by 'B' this will be the program look like #includestdio.h int main(){ int B =4; printf(%d,B); return 0; } therefore, the program will compile and run :)

Re: [algogeeks] Re: Explain

2010-09-10 Thread umesh kewat
HI, Here are some fact related to macros.. its a preprocessor directory so before comping the code will replaced by appropriate macros... these are not comping or executing ..so macros replaced one by one and other fact macro will not replaced the content of other macros... so code of 1st code

Re: [algogeeks] Re: Explain

2010-09-10 Thread saurabh agrawal
Thanks a lot umesh...but still i am in confusion that: after first processing : A is replaced by B after second proecessing B is replaced by A then why again this A is not being replaced by #define A macro.. why it is not going in an infinite loop...because i think there is no fiexed order of

[algogeeks] Re: Explain

2010-09-10 Thread Ukil
Instead of blindly looking for answer, do gcc -E yourfilename.c. It will produce o/p after preprocessing. See what's happening there? On Sep 10, 3:55 pm, saurabh agrawal saurabh...@gmail.com wrote: Thanks a lot umesh...but still i am in confusion that: after first processing : A is replaced by

[algogeeks] majority element in array in O(n)

2010-09-10 Thread bittu
i think my concept is right lets us take array a[1..n];={1,1,1,2,1,3}; n=6; n/2+1=4; so take another array aux[]; which is very helpful to findout hw much time each elemnt arrive in a so its count teh no. of time.. fro i=0 to n aux[a[i]]++; so aux now contains aux[]={0,4,1,1,0,0}; and just

[algogeeks] Re: majority element in array in O(n)

2010-09-10 Thread Dave
One problem in your algorithm is that the additional array has to be large enough to handle all of the values in the array, so, e.g., multiply all of your values by a million and you will see that the work goes up by a factor of a million. It can be done without the additional array, and

[algogeeks] Re: majority element in array in O(n)

2010-09-10 Thread jagadish
Hi Bittu, Your algorithm uses Linear extra space. which is proportional to the input used. There is a better algorithm which is linear in time and does alot better . int Majoritycount(int [] A) { int ctr=1; //counter is a variable to indicate the relative importance of the element. as

Re: [algogeeks] Re: Explain

2010-09-10 Thread Ayush Mittal
first all the preprocessor statementa are executed where all A's are replace by B now the code looks like #includestdio.h int main(){ int B =4; #define A B #define B B printf(%d,B); return 0; } after words second preprocessor statement get executed and all B's by B get replaced #includestdio.h

[algogeeks] Given an array, find out if there exists a pair of nos. that adds up to a sum 'x'

2010-09-10 Thread bittu
Q Given an array, find out if there exists a pair of nos. that adds up to a sum 'x' in O(n) possible,, -- 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 unsubscribe from

[algogeeks] Re: Given an array, find out if there exists a pair of nos. that adds up to a sum 'x'

2010-09-10 Thread jagadish
Hi, O(n) solution is possible if the array is presorted! Else i think it is NOT. 1.Have two ptrs (one from first and other to track the array from last) 2.s=a[left]+a[right] 3.if(ssum) left++; else if(ssum) right--; else print sum found On Sep 10, 10:19 pm, bittu shashank7andr...@gmail.com

[algogeeks] download free PPT and PDF files related to computer science.

2010-09-10 Thread alamzeb
visit computerscienceppt.blogspot.com to download free PPT and PDF files related to computer science..site updated daily! -- 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] Excellent Compilation of Interview Questions

2010-09-10 Thread Shashank Krishna
Excellent Compilation of Interview Questions Visit http://www.cracktheinterview.org/ -- 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 unsubscribe from this group, send email to

Re: [algogeeks] Excellent Compilation of Interview Questions

2010-09-10 Thread ashish agarwal
aham aham On Fri, Sep 10, 2010 at 12:56 PM, Shashank Krishna sasan...@gmail.comwrote: Excellent Compilation of Interview Questions Visit http://www.cracktheinterview.org/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] Excellent Compilation of Interview Questions

2010-09-10 Thread Anand
Really nice awesome On Fri, Sep 10, 2010 at 1:06 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: aham aham On Fri, Sep 10, 2010 at 12:56 PM, Shashank Krishna sasan...@gmail.comwrote: Excellent Compilation of Interview Questions Visit http://www.cracktheinterview.org/ --