Re: [algogeeks] Re: Microsoft interview question

2010-09-25 Thread mohit ranjan
@Ashita, Your logic is fine for one vs one game, but as per question it's one vs many game Any idea what is that ? Mohit On Sat, Sep 25, 2010 at 1:18 PM, ashita dadlani ash@gmail.com wrote: 1.The soldiers are initially placed at row 2 or row 7th(each-one of white and either of

Re: [algogeeks] Fwd: another help please

2010-09-25 Thread rahul rai
Yes , i. Can , and i did , but is't there a shortcut . I want to know that 2010/9/24, mohit ranjan shoonya.mo...@gmail.com: Dear Rahul, Can you try writing hex digits in binary and try. 0x77 -- 0111 0111 0x03 -- 0011 --- AND 0011 -- 0x03

Re: [algogeeks] Re: Number problem

2010-09-25 Thread Nishant Agarwal
@yellow your code turns 1000,100,10,2270,12130 to 1,1,1,27,123 repectively simply it removes all trailing zeros ... On Wed, Sep 22, 2010 at 8:10 PM, Yellow Sapphire pukhraj7...@gmail.comwrote: My Solution. Almost same as above but the flag is set by using bits. #define SETFLAG(flag,

Re: [algogeeks] Re: Number problem

2010-09-25 Thread Nishant Agarwal
Here's the code int rem_dup(int n) { int *a,i,c,t,d,count[10]={0},arr[20],j=0,sum=0; a=(int *)malloc(sizeof(a)); for(i=0;n0;i++)//storing each digit of number in an array { a[i]=n%10; n=n/10; } c=d=i-1; i=0; while(ic)//reversing the array {

[algogeeks] Bitwise operator - Adobe

2010-09-25 Thread Krunal Modi
Q: Write an algorithm to compute the next multiple of 8 for a given positive integer using bitwise operators. Example, (a) For the number 12, the next multiple of 8 is 16. (b) For the number 16, the next multiple of 8 is 24. - I have written a code using bitwise

[algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread Krunal Modi
Basically, I am starting from (ans=)0 checking if it has become greater than n, if not repeat(means, add 8) else answer is found. -- 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.

Re: [algogeeks] Amazon Interview

2010-09-25 Thread Soundar
http://michael.dipperstein.com/rle/index.html Step 1. Set the previous symbol equal to an unmatchable value. Step 2. Read the next symbol from the input stream. Step 3. If the symbol is an EOF exit. Step 4. Write out the current symbol. Step 5. If the

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread rahul
Example, (a) For the number 12, the next multiple of 8 is 16. (b) For the number 16, the next multiple of 8 is 24. did u mean next multiple of 8 greater than given number(12 or 16). ? On Sat, Sep 25, 2010 at 5:28 PM, Krunal Modi krunalam...@gmail.com wrote: Basically, I am starting from

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread Rahul Singal
let the number be x . solution = x - (x%8) + 8; -- 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] Re: Bitwise operator - Adobe

2010-09-25 Thread Baljeet Kumar
solution = ((x3) + 1)3; On Sat, Sep 25, 2010 at 5:45 PM, Rahul Singal rahulsinga...@gmail.comwrote: let the number be x . solution = x - (x%8) + 8; -- 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] Re: Adobe Question

2010-09-25 Thread Nikhil Jindal
The answer would be: (log1+1) + (log2+1) + (log3+1) + (log4+1) + ... + (log(n-1)+1) which is equal to: (log1+log2+log3+...+log(n-1)) + (n-1) == *log((n-1)!) + (n-1)* where, log everywhere is assumed to be in base 2 *This according to me will be the final answer!* * * *Cheers* *Nikhil Jindal * On

[algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread rajess
this wont work if x=24 i.e.multiple of 8 On Sep 25, 6:00 pm, Baljeet Kumar baljeetk...@gmail.com wrote: solution = ((x3) + 1)3; On Sat, Sep 25, 2010 at 5:45 PM, Rahul Singal rahulsinga...@gmail.comwrote: let the number be x . solution = x - (x%8) + 8; -- You received this message

[algogeeks] next multiple of 8

2010-09-25 Thread rajess
scan last(left) 4 bits .if the bits are not 1000.make them 1000.else scan from left till u find first one(1).make this bit 1.and make last(left) bits as 1000 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] BST in BT

2010-09-25 Thread mac adobe
How would you identify a binary search tree of maximum nodes in a binary tree ? -- 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

[algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread Dave
answer = (x || 7) + 1; Dave On Sep 25, 6:56 am, Krunal Modi krunalam...@gmail.com wrote: Q: Write an algorithm to compute the next multiple of 8 for a given positive integer using bitwise operators. Example, (a) For the number 12, the next multiple of 8 is 16. (b) For the number 16, the

[algogeeks] Re: next multiple of 8

2010-09-25 Thread Dave
Simpler: answer = (x || 7) + 1 Dave On Sep 25, 10:14 am, rajess rajess1...@yahoo.com wrote: scan last(left) 4 bits .if the bits are not 1000.make them 1000.else scan from left till u find first one(1).make this bit 1.and make last(left) bits as 1000 -- You received this message because you

[algogeeks] Re: ReVerse a string using recursion

2010-09-25 Thread Krunal Modi
I agree with Nishant. For inplace replacement we need to swap two place for that we need index, which is not possible without additional variables. -- 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] Re: Number problem

2010-09-25 Thread Yellow Sapphire
My code failed because it was reversing the digits and thus 0 was getting added in the front which resulted in nothing. If allowed we can use a char array else will have to find a solution which does not reverse the digits of the number. -- You received this message because you are subscribed

Re: [algogeeks] Re: ReVerse a string using recursion

2010-09-25 Thread albert theboss
please let me know solution using extra memory. -- 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] Re: ReVerse a string using recursion

2010-09-25 Thread Nishant Agarwal
@albert why r u asking for a non optimal solution?? On Sat, Sep 25, 2010 at 11:24 PM, albert theboss alberttheb...@gmail.comwrote: please let me know solution using extra memory. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread Baljeet Kumar
@rajess It works for all the cases. On Sat, Sep 25, 2010 at 8:42 PM, rajess rajess1...@yahoo.com wrote: this wont work if x=24 i.e.multiple of 8 On Sep 25, 6:00 pm, Baljeet Kumar baljeetk...@gmail.com wrote: solution = ((x3) + 1)3; On Sat, Sep 25, 2010 at 5:45 PM, Rahul Singal

[algogeeks] Re: ReVerse a string using recursion

2010-09-25 Thread Gene
Here is another approach. Remove the first character. Reverse the rest of the string recursively. Append the character at the end. Others have given solutions along these lines, but they have various mistakes. Here's one that I believe is correct. As pointed out already, this is not a good

Re: [algogeeks] Bitwise operator - Adobe

2010-09-25 Thread Terence
If +,-,*,/ is completely forbidden, I think at least one loop is needed. Here is my solution: int next8mult (int n) { n = (n ~7);// clear the least 3 bit to make multiple of 8 int r = 8; while(r) { // add 8 to n int r1 = (nr) 1; // get

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread coolfrog$
@Dave very nice one line solution.. we all are revolving around x3 concept... On Sat, Sep 25, 2010 at 10:17 PM, Dave dave_and_da...@juno.com wrote: answer = (x || 7) + 1; Dave On Sep 25, 6:56 am, Krunal Modi krunalam...@gmail.com wrote: Q: Write an algorithm to compute the next

Re: [algogeeks] Re: BST in BT

2010-09-25 Thread mac adobe
No parody .. that would be another doubt :( On Sat, Sep 25, 2010 at 11:03 PM, prodigy 1abhishekshu...@gmail.com wrote: By maintaining a current maximum and a global maximum. You do know how to verify a BT is BST . http://pastebin.com/xwXXTEnP On Sep 25, 9:04 pm, mac adobe

Re: [algogeeks] Re: BST in BT

2010-09-25 Thread mac adobe
@parody :..and how would that find me a maximum size BST .. ?? ( for checking if this BT is BST i would do inorder traversal and see if it is increasing ) On Sun, Sep 26, 2010 at 11:10 AM, mac adobe macatad...@gmail.com wrote: No parody .. that would be another doubt :( On Sat, Sep

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread saurabh agrawal
Simple one line solution without looping and efficient : i=(i7)?(i|7)+1:i) On Sun, Sep 26, 2010 at 8:43 AM, coolfrog$ dixit.coolfrog.div...@gmail.comwrote: @Dave very nice one line solution.. we all are revolving around x3 concept... On Sat, Sep 25, 2010 at 10:17 PM, Dave

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread kusuma sanjeev
@Saurab: Nice solution On Sun, Sep 26, 2010 at 11:27 AM, saurabh agrawal saurabh...@gmail.comwrote: Simple one line solution without looping and efficient : i=(i7)?(i|7)+1:i) On Sun, Sep 26, 2010 at 8:43 AM, coolfrog$ dixit.coolfrog.div...@gmail.com wrote: @Dave very nice one line