Re: [algogeeks] Re: DP

2010-10-09 Thread Amit Mittal
first player can check if sum of notes placed in the odd position are greater than the sum of notes placed in the even position and can pick accordingly and will always win. On Sat, Oct 9, 2010 at 10:52 AM, Anand anandut2...@gmail.com wrote: Yes. http://codepad.org/2KFrv8cs On Fri, Oct 8,

[algogeeks] plz explain output

2010-10-09 Thread ankush
#includestdio.h void main() { int x; float t; scanf(%f,t); printf(%f\n,t); x=90; printf(%f\n,x); { x=1; printf(%f\n,x); { x=30; printf(%d\n,x);

Re: [algogeeks] Re: DP

2010-10-09 Thread nishaanth
http://people.csail.mit.edu/bdean/6.046/dp/ check out this lecture... -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] catalan numbers

2010-10-09 Thread keyankarthi
can anyone suggest how to implement Catalan numbers.. upper limit 1000, consider modulo 1 -- 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,

[algogeeks] Re: catalan numbers

2010-10-09 Thread Dave
There is a recurrence for computing the n+1st Catalan Number from the 0th through the nth Catalan Numbers. See http://en.wikipedia.org/wiki/Catalan_number. Something like this code fragment ought to do, assuming long long int is 64 bits: int CatalanNumber[1001]; int i,n; long long int x;

Re: [algogeeks] plz explain output

2010-10-09 Thread Ashutosh Tripathi
hey! i am also unable to explain but one thing i got if we use %d in place of %f,we will get the correct output. we must use %d as x is of int data type.so thq code is itself wrong. or u can change x to float data type -- Ashutosh Tripathi UG Student Computer

[algogeeks] Re: plz explain output

2010-10-09 Thread @shu
On Oct 9, 11:51 am, Ashutosh Tripathi ashu.nit...@gmail.com wrote: hey! i am also unable to explain but one thing i got if we use %d in place of %f,we will get the correct output. we must use %d as x is of int data type.so the code is itself wrong. or u

Re: [algogeeks] Re: plz explain output

2010-10-09 Thread DIPANKAR DUTTA
printf is very week to convert int to float or vice versa.. please read D. Ritchie for details. On 10/9/10, @shu ashu.nit...@gmail.com wrote: On Oct 9, 11:51 am, Ashutosh Tripathi ashu.nit...@gmail.com wrote: hey! i am also unable to explain but one thing i got if we use %d in

Re: [algogeeks] double tower of hanoi

2010-10-09 Thread ravindra patel
@Terence Sorry, had misunderstood your solutions earlier. Your approach and calculations both are correct and more efficient than my soln. Initially I was not much convinced with the assumption that in the first solution, all but last pair are in their original order. Later realized that its

[algogeeks] Re: first k digits of n^n.

2010-10-09 Thread Mridul Malpani
@ navin :take care of conversion from double to int. i have submitted this solution only. On Oct 5, 8:59 pm, navin navin.myhr...@gmail.com wrote: @Dave k=9 only for this problem. @Mridul: for input  2 19423474 8 19423474 9 output: 16307490 26110976 163074908 826110976 but actual

Re: [algogeeks] Re: catalan numbers

2010-10-09 Thread GUNJAN BANSAL
Hi, The implementation that you are trying to do is incorrect, this is primarly because division is not commutative over modulous. You can check that with simple examples. eg 111 is divisible by 3, but taking modulus with 100 we get 11 which is not divisible by 3. Catalan number is of the form

Re: [algogeeks] Re: first k digits of n^n.

2010-10-09 Thread GUNJAN BANSAL
even solution has been rejected around 5 times, I simply copy pasted the code for a try but still it wont work. Code pasted at http://paste.pocoo.org/show/273254/ please help !! On Sat, Oct 9, 2010 at 11:36 PM, Mridul Malpani malpanimri...@gmail.comwrote: @ navin :take care of conversion from

[algogeeks] Re: catalan numbers

2010-10-09 Thread Dave
@Gunjan: If you were referring to my implementation (it is the only one that I see), you'll notice that I used a different recurrence, the second formulation in the properties section of the Wikipedia page I referenced, that starts with C_0 = 1. It only uses multiplication, and multiplication and

Re: [algogeeks] Re: catalan numbers

2010-10-09 Thread GUNJAN BANSAL
Dave, Yep sorry, i over looked the implementation, its better than mine for a all numbers less than n :). I hope it don't happen again. On Sun, Oct 10, 2010 at 12:38 AM, Dave dave_and_da...@juno.com wrote: @Gunjan: If you were referring to my implementation (it is the only one that I see),

Re: [algogeeks] Re: catalan numbers

2010-10-09 Thread GUNJAN BANSAL
Just change it to int CatalanNumber[1001]; int i,n; long long int x; CatalanNumber[0] = 1; *CatalanNumber[1]=1; for( n = 2 *; n 1000 ; ++n ) { x = 0; for( i = 0 ; i = n ; ++i ) x += (long long int)CatalanNumber[i] * (long long int)CatalanNumber[n-i]; CatalanNumber[n+1] =

[algogeeks] C puzzle

2010-10-09 Thread Soumya Prasad Ukil
#includestdio.h main() { char a ='c'; typedef char* charp; const charp p=a; p++; } Why p is a constant pointer ? -- regards, soumya prasad ukil -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Re: DP

2010-10-09 Thread Gene
This is a nice page, but the solution closest to this problem requires n to be even. Using the same technique to take care of odd n cases is messy. The solution I posted seems simpler, and its efficiency is the same. On Oct 9, 9:03 am, nishaanth nishaant...@gmail.com wrote:

Re: [algogeeks] C puzzle

2010-10-09 Thread umesh kewat
Dear prasad after pre-compiling the expression is like const char* p = a, so now u can understand y its const pointer On Sun, Oct 10, 2010 at 1:07 AM, Soumya Prasad Ukil ukil.sou...@gmail.comwrote: #includestdio.h main() { char a ='c'; typedef char* charp; const charp

Re: [algogeeks] C puzzle

2010-10-09 Thread kusuma sanjeev
const char * = pointer to a const integer rt? Correct me if am wrong. On Sun, Oct 10, 2010 at 8:31 AM, umesh kewat umesh1...@gmail.com wrote: Dear prasad after pre-compiling the expression is like const char* p = a, so now u can understand y its const pointer On Sun, Oct 10, 2010 at

Re: [algogeeks] C puzzle

2010-10-09 Thread Soumya Prasad Ukil
@kewat, If it is const char*, then compilation won't give error. But it is something like char *const. But how? On 10 October 2010 08:31, umesh kewat umesh1...@gmail.com wrote: Dear prasad after pre-compiling the expression is like const char* p = a, so now u can understand y

Re: [algogeeks] C puzzle

2010-10-09 Thread kusuma sanjeev
charp is not a textual replacement of char* since it is typedef. const charp p and charp const p are both equivalent to p being a constant pointer to character. On Sun, Oct 10, 2010 at 10:19 AM, Soumya Prasad Ukil ukil.sou...@gmail.comwrote: @kewat, If it is const char*, then

[algogeeks] 2 elements with sum = x

2010-10-09 Thread Harshal
Design an *O(n)*-time algorithm that, given a real number *x * and a sorted array *S* of *n * numbers, determines whether or not there exist two elements in *S* whose sum is exactly *x *. since array is already sorted, doing binary search for x-S[i] ,for each element indexed at i will give a