Re: [algogeeks] Google written test

2012-03-19 Thread atul anand
@Gene : your code will work fine by changing the argument passed from main(), you just need to call rite f(n, 1, 1); from main instead of f(n, 1, 0); On Mon, Mar 19, 2012 at 10:10 AM, atul anand atul.87fri...@gmail.comwrote: @all : i guess question is on Fibonacci coding. here you can find

[algogeeks] Re: DocumentFormat.OpenXml Library

2012-03-19 Thread Manjay
If anyone have any idea please share . On Mar 15, 12:06 pm, Manjay kumar manjay.bit...@gmail.com wrote: DocumentFormat.OpenXml library of .Net On Thu, Mar 15, 2012 at 12:35 PM, Manjay manjay.bit...@gmail.com wrote: From where can I have Knowledge of this library of .NET. If anyone have any

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread srikanth reddy malipatel
hii supraja can u mail me the link for your blog plz. On Sun, Mar 18, 2012 at 6:38 PM, Supraja Jayakumar suprajasank...@gmail.com wrote: Hi Others are also welcome to comment on the code. If links are allowed in algogeeks, I might send my wordpress blog link that explains this problem in

[algogeeks] Re: Google written test

2012-03-19 Thread Gene
Thanks. I noticed this too. If the n'th 1/0 digit is supposed to correspond with the n'th fibonacci number, then my original code would have been right. But the example isn't done this way. I fixed the code to match the example the evening of the 18th (Eastern time), but I guess the change is

[algogeeks] Re: Vertical Sum in a given Binary Tree

2012-03-19 Thread vikas
verticalSum( node * root, List * sum) { if(root == null) return; sum-data += root-data; verticalSum(root-left, sum-left); verticalSum(root-right, sum-right); } 1 / \ 2 3 / \/ \ 4 5 6 7 a b c d e Vsum(1, c) c= 1 Vsum (2,

Re: [algogeeks] Re: Google written test

2012-03-19 Thread shady
@gene it does show your updated code. @atul from the given input it seems different from Fibonacci encoding. On Mon, Mar 19, 2012 at 5:32 PM, Gene gene.ress...@gmail.com wrote: Thanks. I noticed this too. If the n'th 1/0 digit is supposed to correspond with the n'th fibonacci number, then

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread shady
nice explanation aman and prashant 1(0) / \ 2(-1) 3(1) / \ / \ 4(-2) 5(0) 6(0) 7(2) As you see this example, each node has an extra attribute(not necessary though) which tells its distance from the root node. Take map and as you traverse the tree in any order, add the count to the map value.

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread shady
anything that can help people learn is always allowed. :) On Sun, Mar 18, 2012 at 6:38 PM, Supraja Jayakumar suprajasank...@gmail.com wrote: Hi Others are also welcome to comment on the code. If links are allowed in algogeeks, I might send my wordpress blog link that explains this problem

Re: [algogeeks] Re: Google written test

2012-03-19 Thread atul anand
@Gene : yeah i skipped ur updated code...its dere @shady : it is similar to fib encoding...you just need to reverse the output from gene code and append '1' at the end... while decoding it ...this extra '1' is not considered.. i am nt sure but maybe the reason for adding '1' at the end is to

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread rahul sharma
@supraja ..can u give example..code not needed.. @all..plz post me example.i dnt know what is vertical sum..i wana know only that..thnx... On Mon, Mar 19, 2012 at 7:31 PM, shady sinv...@gmail.com wrote: anything that can help people learn is always allowed. :) On Sun, Mar 18, 2012 at 6:38

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread shady
if tree is like 1 / \ 2 3 / \ / \ 4 5 6 7 / \ 12 -8 then vertical sums are 12(1 + 5 + 6) 2 4 -6(2+-8) 3 7 12 On Mon, Mar 19, 2012 at 9:05 PM, rahul sharma rahul23111...@gmail.comwrote: @supraja ..can u give example..code not needed.. @all..plz post me example.i dnt know what is vertical

Re: [algogeeks] Vertical Sum in a given Binary Tree

2012-03-19 Thread shady
oops no 2 there On Mon, Mar 19, 2012 at 9:36 PM, shady sinv...@gmail.com wrote: if tree is like 1 / \ 2 3 / \ / \ 4 5 6 7 / \ 12 -8 then vertical sums are 12(1 + 5 + 6) 2 4 -6(2+-8) 3 7 12 On Mon, Mar 19, 2012 at 9:05 PM, rahul sharma rahul23111...@gmail.comwrote: @supraja

[algogeeks] Run Length Decoding... inplace

2012-03-19 Thread ATul SIngh
This was a MS question asked recently on Run length Decoding. I was given Input- a3b5c3d2 And the output should be ddcccbaaa Assuming that the memory given is sufficient to accomodate the whole string. And this conversion should be inplace. ie the output string should not use another array.

Re: [algogeeks] Run Length Decoding... inplace

2012-03-19 Thread shady
keep a pointer and just write the count with the corresponding character on the same character array. On Mon, Mar 19, 2012 at 10:38 PM, ATul SIngh atulsingh7...@gmail.comwrote: This was a MS question asked recently on Run length Decoding. I was given Input- a3b5c3d2 And the output should be

Re: [algogeeks] Run Length Decoding... inplace

2012-03-19 Thread Ashish Goel
the catch here is how you represent aa? Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Mar 20, 2012 at 1:56 AM, shady sinv...@gmail.com wrote: keep a pointer and just write the count with the corresponding character on the same

[algogeeks] Re: Run Length Decoding... inplace

2012-03-19 Thread Gene
It's not hard if all the run lengths are at least 2. void decode(char *buf, int in_size, int buf_size) { int i, j, rl, p; char t; // Reverse the input. for (i = 0, j = in_size - 1; i j; i++, j--) { t = buf[i]; buf[i] = buf[j]; buf[j] = t; } // Copy to end of buffer (carefully)