Re: [algogeeks] Re: spoj NKTM

2011-06-16 Thread kartik sachan
without priority queue its .08 and with priority queue its .0.00 -- 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] FIBONACCI problem.

2011-06-16 Thread vaibhav agarwal
shuldn't it be f(246+m)%10 last one On Thu, Jun 16, 2011 at 9:04 AM, saurabh singh saurab...@gmail.com wrote: t,m;f(n){return n=2?1:f(n-1)+f(n-2);} main(){scanf(%d,t);while(t--)scanf(%d,m)printf(%d\n,f(m+11)-f(m+1)+f(6+m)%10));} My best attempt with the c code..132 bytes still Now

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread kartik sachan
ACTUALLY FIBBONACCI SERIERS REAPEAT AFTER 60 TERM SO 246%60 WILLBE 6 SO WE ONLY HAVE TO FIND M+6 TERM -- 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

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread vaibhav agarwal
got it repetition in cycles of 60 On Thu, Jun 16, 2011 at 12:35 PM, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: shuldn't it be f(246+m)%10 last one On Thu, Jun 16, 2011 at 9:04 AM, saurabh singh saurab...@gmail.comwrote: t,m;f(n){return n=2?1:f(n-1)+f(n-2);}

Re: [algogeeks] [brain teaser ] Number Trick Riddle

2011-06-16 Thread sunny agrawal
n^2 On Thu, Jun 16, 2011 at 12:41 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *Number Trick Riddle - 16 june * * * * *** ** *Sonal asked the class to see if they could find the sum of the first 50 odd numbers. As everyone settled down to their addition, Lavesh ran to her and said, 'The

Re: [algogeeks] DE Shaw Q

2011-06-16 Thread Nitish Garg
Nice Solution! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/PGCJcmtuYqEJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe

Re: [algogeeks] Re: find output.

2011-06-16 Thread amit kumar
//kk //In place of char *p=hai friends,*p1; if i declare as char p[]=hai friends; char *p1; //then ?? On Thu, Jun 16, 2011 at 8:16 AM, DIPANKAR DUTTA dutta.dipanka...@gmail.comwrote: It's ok.. char *p=hai friends...not correct bcz you did allocate memory for that string but assiging

Re: [algogeeks] Re: find output.

2011-06-16 Thread sunny agrawal
The place where strict constness is not enforced is with character array literals. You can say char* cp = howdy; and the compiler will accept it without complaint. This is technically an error because a character array literal (“howdy” in this case) is created by the compiler as a constant

[algogeeks] MST (BLINNET) problem on SPOJ

2011-06-16 Thread KK
www.spoj.pl/problems/BLINNET/ Here is the code for the same... Its not getting AC in SPOJ m not able to figure out wheres the hole in this... plzz help #includeiostream #includestring #includevector #includelist #includequeue #define MAXINT (int)9e9 #define TR(a,it)

Re: [algogeeks] Re: find output.

2011-06-16 Thread LALIT SHARMA
++*p++ == ++(*p++) , increments the value stored at p , and also increments p . On Thu, Jun 16, 2011 at 1:10 PM, sunny agrawal sunny816.i...@gmail.comwrote: The place where strict constness is not enforced is with character array literals. You can say char* cp = howdy; and the compiler

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread PRAMENDRA RATHi rathi
without DP it will be TLE.. - PRAMENDRA RATHI NIT ALLAHABAD On Thu, Jun 16, 2011 at 9:04 AM, saurabh singh saurab...@gmail.com wrote: t,m;f(n){return n=2?1:f(n-1)+f(n-2);}

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread • » νιρυℓ « •
My AC solution is O(1). On Thu, Jun 16, 2011 at 2:29 PM, PRAMENDRA RATHi rathi prathi...@gmail.comwrote: without DP it will be TLE.. - PRAMENDRA RATHI NIT ALLAHABAD On Thu, Jun 16, 2011 at 9:04 AM, saurabh singh saurab...@gmail.comwrote:

Re: [algogeeks] Re: find output.

2011-06-16 Thread amit kumar
lalit u r wrong On Thu, Jun 16, 2011 at 1:44 PM, LALIT SHARMA lks.ru...@gmail.com wrote: ++*p++ == ++(*p++) , increments the value stored at p , and also increments p . On Thu, Jun 16, 2011 at 1:10 PM, sunny agrawal sunny816.i...@gmail.comwrote: The place where strict constness is not

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread saurabh singh
Well dont know...My pure recursive solution in python got AC in 0.07s(93 bytes).No DP involved.And I don't think python is faster than c? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread saurabh singh
Very sorry i did used memoization..Ya not possible with o(2^n) solution...Apologies once again On Thu, Jun 16, 2011 at 3:21 PM, saurabh singh saurab...@gmail.com wrote: Well dont know...My pure recursive solution in python got AC in 0.07s(93 bytes).No DP involved.And I don't think python

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread Piyush/Parrik Ahuja
hint : think it as matrix raised to some power ( then u can compute that in log(n) ) or other way around is to find cycle length . :-) On Thu, Jun 16, 2011 at 3:56 PM, saurabh singh saurab...@gmail.com wrote: Very sorry i did used memoization..Ya not possible with o(2^n)

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread kartik sachan
@vipul what algo u have applied for o(1)?? -- 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.

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread • » νιρυℓ « •
Binet's Formula. ( keep shortening :P ) On Thu, Jun 16, 2011 at 5:57 PM, kartik sachan kartik.sac...@gmail.comwrote: @vipul what algo u have applied for o(1)?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] [brain teaser ] Number Trick Riddle

2011-06-16 Thread Nitish Garg
n^2. Easy One! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/ztyVPtQgX64J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread PRAMENDRA RATHi rathi
simple with AWK - PRAMENDRA RATHI NIT ALLAHABAD 2011/6/16 • » νιρυℓ « • vipulmehta.1...@gmail.com Binet's Formula. ( keep shortening :P ) On Thu, Jun 16, 2011 at 5:57 PM, kartik sachan kartik.sac...@gmail.comwrote: @vipul what algo u have applied

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread kartik sachan
most simple with bash..using formula 11*f(n+6)+11*f(n+6)%10 -- 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: Explain the o/p

2011-06-16 Thread Kamakshii Aggarwal
I have read this link,still i am not getting.Can anybody help?? On 6/16/11, Kamakshii Aggarwal kamakshi...@gmail.com wrote: I have read this link,still my not getting.Can anybody help?? On 6/15/11, Maksym Melnychok keym...@gmail.com wrote: that's floating point for you.

Re: [algogeeks] Re: find output.

2011-06-16 Thread Kamakshii Aggarwal
i still din't get the solution..please explain.. On 6/16/11, LALIT SHARMA lks.ru...@gmail.com wrote: ++*p++ == ++(*p++) , increments the value stored at p , and also increments p . On Thu, Jun 16, 2011 at 1:10 PM, sunny agrawal sunny816.i...@gmail.comwrote: The place where strict

Re: [algogeeks] Re: Explain the o/p

2011-06-16 Thread Kamakshii Aggarwal
I have read this link,still my not getting.Can anybody help?? On 6/15/11, Maksym Melnychok keym...@gmail.com wrote: that's floating point for you. http://en.wikipedia.org/wiki/Floating_point -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

Re: [algogeeks] MSFT Q

2011-06-16 Thread Srikrishan Malik(gmail)
BK tree would be a good DS for this. -Sri On Wed, Jun 15, 2011 at 6:00 PM, keyan karthi keyankarthi1...@gmail.com wrote: we can even add word completion :) On Wed, Jun 15, 2011 at 5:25 PM, immanuel kingston kingston.imman...@gmail.com wrote: Use a trie data structure and pre-load it with

Re: [algogeeks] Re: find output.

2011-06-16 Thread keyan karthi
hi friends is a string literal.. ie the string hi friends is stored somewhere and a pointer to its base address is returned to pointer p at the time of initialization... u can always make use of this pointer to traverse / access the literal but u cant alter tat in the code, u r trying to do a ++

Re: [algogeeks] Re: find output.

2011-06-16 Thread Navneet Gupta
@Sunny, it is good that you follow Bruce Eckel, but copy pasting the exact thing? :) On Thu, Jun 16, 2011 at 7:34 PM, keyan karthi keyankarthi1...@gmail.comwrote: hi friends is a string literal.. ie the string hi friends is stored somewhere and a pointer to its base address is returned to

Re: [algogeeks] Re: find output.

2011-06-16 Thread sunny agrawal
yes copy pasting the exact thing :) for better understanding :) On Thu, Jun 16, 2011 at 8:06 PM, Navneet Gupta navneetn...@gmail.comwrote: @Sunny, it is good that you follow Bruce Eckel, but copy pasting the exact thing? :) On Thu, Jun 16, 2011 at 7:34 PM, keyan karthi

Re: [algogeeks] Re: find output.

2011-06-16 Thread Navneet Gupta
Then i would suggest you give the original reference in such cases for still better understanding :) Be it a book or a website. On Thu, Jun 16, 2011 at 8:13 PM, sunny agrawal sunny816.i...@gmail.comwrote: yes copy pasting the exact thing :) for better understanding :) On Thu, Jun 16, 2011 at

[algogeeks] plz xplain the output

2011-06-16 Thread amit the cool
#define f(g,g2) g##g2 main() { int var12=100; printf(%d,f(var,12)); } output-100 -- 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: find output.

2011-06-16 Thread Arpit Sood
@sunny thanks, that post did clear the confusion. On Thu, Jun 16, 2011 at 8:17 PM, Navneet Gupta navneetn...@gmail.comwrote: Then i would suggest you give the original reference in such cases for still better understanding :) Be it a book or a website. On Thu, Jun 16, 2011 at 8:13 PM,

Re: [algogeeks] plz xplain the output

2011-06-16 Thread arjoo kumar
g##g2 means gg2 i,e concat g g2 by the property of #define it is replace where it is called. On Thu, Jun 16, 2011 at 8:36 PM, amit the cool amitthecoo...@gmail.comwrote: #define f(g,g2) g##g2 main() { int var12=100; printf(%d,f(var,12)); } output-100 -- You received this message

Re: [algogeeks] Re: find output.

2011-06-16 Thread sunny agrawal
@Arpit Thanks to Bruce Eckel :D On Thu, Jun 16, 2011 at 9:00 PM, Arpit Sood soodfi...@gmail.com wrote: @sunny thanks, that post did clear the confusion. On Thu, Jun 16, 2011 at 8:17 PM, Navneet Gupta navneetn...@gmail.comwrote: Then i would suggest you give the original reference in such

[algogeeks] String Swapping Problem

2011-06-16 Thread udit sharma
#includestdio.hvoid swap(char *,char *);int main(){char *ps[2]={ Hello, Good Mornning, };swap(ps[0],ps[1]);printf(%s \t %s\n,ps[0],ps[1]);return 0;} void swap(char *p,char *q){char *t;t=p;p=q;q=t;} why the output is: HelloGood Mornning --

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread DIPANKAR DUTTA
instead of calling swap(ps[0],ps[1]) can u try with swap(ps[0],ps[1]) or swap(ps[0][0],ps[1][0]) ? On Fri, Jun 17, 2011 at 5:05 AM, udit sharma sharmaudit...@gmail.comwrote: #includestdio.hvoid swap(char *,char *);int main(){char *ps[2]={ Hello, Good Mornning,

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread udit sharma
Ohh Sry... The qus was: #includestdio.hvoid swap(char *,char *);int main(){char *ps[2]={ Hello, Good Mornning, };swap(ps[0],ps[1]);printf(%s \t %s\n,ps[0],ps[1]);return 0;} void swap(char *p,char *q){char *t;t=p;p=q;q=t;} why the output is: Hello

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread Rohit Sindhu
The function swap just swaps it's local copy of pointers which does not mean that it swap array elements. You have to do it explicitly. On Fri, Jun 17, 2011 at 3:17 AM, udit sharma sharmaudit...@gmail.comwrote: Ohh Sry... The qus was: #includestdio.hvoid swap(char *,char *);int

[algogeeks] Operating System

2011-06-16 Thread Antony Kotre
Please suggest me some good online tutrial on operating system ? Thanks in advance -- 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] String Swapping Problem

2011-06-16 Thread Rohit Sindhu
#includestdio.h void swap(char **p,char **q) { char *t; t=*p; *p=*q; *q=t; } int main(){ char *ps[2]={ Hello, Good Morning, }; swap( ps[0] , ps[1]); printf(%s \t %s\n,ps[0],ps[1]); return 0; } This one breaks the ice ... as you have to change the contents of the array

[algogeeks] Need an Algorithm Enginner for an awesome new global shopping startup! (already have 100,000 registered users)

2011-06-16 Thread Rigo
If interested, shoot me an email at rodrigo.stockebr...@gmail.com -- 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] Need an Algorithm Recommendation

2011-06-16 Thread Rigo
Which algorithm would I use if I had an e-commerce website that captured user data (shopping data, site navigation data, and social media data) and I wanted to come up with a formula that would tell me which products sell best (when they sell best, to whom they sell best, etc...)? Any ideas would

Re: [algogeeks] Re: Explain the o/p

2011-06-16 Thread DIPANKAR DUTTA
This is depending on the precission of floating point number representation (IEEE double pression or single precission ) and how it is handled by the compilers) On Thu, Jun 16, 2011 at 8:50 PM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: I have read this link,still i am not getting.Can

Re: [algogeeks] Re: find output.

2011-06-16 Thread Anand
Question: main() { char str[] = hai friends; char *p,*p1; p = str; p1=p; while(*p != 's') { ++*p++; } printf( %s,p1); } http://codepad.org/24hmvzP5 Ans: ibj!gsjfoes On Thu, Jun 16, 2011 at 9:24 AM, sunny agrawal sunny816.i...@gmail.comwrote: @Arpit Thanks to Bruce

Re: [algogeeks] Need an Algorithm Recommendation

2011-06-16 Thread DIPANKAR DUTTA
I think this can be performed by forming an augumented data strcture (like augmented linked list or BST).. then you can apply the genraral algorithm like sorting searching or graph algo... to performance imporovement you can use cache or has table... On Fri, Jun 17, 2011 at 7:27 AM, Rigo

Re: [algogeeks] help

2011-06-16 Thread DIPANKAR DUTTA
(this is dependon on compiler implementaion)this is due to shortcircuit implementaion of intermidiate code genaration phase of compiler.. please read Aho ullman book of compiler desgn to get more details. On Wed, Jun 15, 2011 at 12:51 AM, snehi jain snehijai...@gmail.com wrote: first

Re: [algogeeks] Adobe Q

2011-06-16 Thread DIPANKAR DUTTA
We can optimize the code using DP... On Wed, Jun 15, 2011 at 8:24 PM, immanuel kingston kingston.imman...@gmail.com wrote: The following is for LCA for 2 nodes in a n-ary tree. A more tougher problem is to find the LCA for n nodes in the same n-ary tree. Node * findLCA (Node *root, Node *

Re: [algogeeks] Re: find output.

2011-06-16 Thread LALIT SHARMA
@amit , Then explain me , in simpler words .. as i am not able to get it ... On 6/17/11, Anand anandut2...@gmail.com wrote: Question: main() { char str[] = hai friends; char *p,*p1; p = str; p1=p; while(*p != 's') { ++*p++; } printf( %s,p1); }