[algogeeks] Re: optimum algo for second largest

2009-10-12 Thread Shishir Mittal
On Mon, Oct 12, 2009 at 1:29 PM, ankur aggarwal ankur.mast@gmail.comwrote: @shishir can u give the ds data structure used is a binary tree, with each node key being the maximum of its two children's key values. Space complexity of implementation of tournament principle is O(n). how would

[algogeeks] Re: optimum algo for second largest

2009-10-12 Thread ankur aggarwal
in that case it is ok.. --~--~-~--~~~---~--~~ 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] ROTATE

2009-10-12 Thread ankur aggarwal
*You are given a integer and you want to rotate the bits of the number by a value x. Consider the right rotation by x means the least significant x bits should go out from left and take the position of most significant x bits.* --~--~-~--~~~---~--~~ You received

[algogeeks] Re: ROTATE

2009-10-12 Thread Raghavendra Sharma
temp = (0x (32 - x)) n; n = (n x) | ( temp (32 -x)); On Mon, Oct 12, 2009 at 5:32 PM, ankur aggarwal ankur.mast@gmail.comwrote: *You are given a integer and you want to rotate the bits of the number by a value x. Consider the right rotation by x means the least significant x

[algogeeks] Re: ROTATE

2009-10-12 Thread ankur aggarwal
@raghav plz give an example wat r u trying 2 do. On Mon, Oct 12, 2009 at 8:41 PM, Raghavendra Sharma raghavendra.vel...@gmail.com wrote: temp = (0x (32 - x)) n; n = (n x) | ( temp (32 -x)); On Mon, Oct 12, 2009 at 5:32 PM, ankur aggarwal ankur.mast@gmail.comwrote: *You

[algogeeks] Re: Interesting array multiplication problem

2009-10-12 Thread katrohit
one question though? why do you prefer division by bit operations, when there is / operator ( 32 bit div operation is inbuilt in almost all the processors so it can be done in constant time) also you recursion is not Tail-recursive so stack will grow like crazy!! On Oct 10, 9:36 pm, harit

[algogeeks] Re: ROTATE

2009-10-12 Thread GauravNITW
How abt this..? for(i=0;ix;i++) { res=no1U; no=no1; if(res==1) no=no|32768U; else no=no|0U; } printf(\nFinal value %u,no); On Oct 12, 8:11 pm, Raghavendra Sharma raghavendra.vel...@gmail.com wrote: temp =  (0x (32 - x)) n; n  =  (n   x) | ( temp (32

[algogeeks] Re: ROTATE

2009-10-12 Thread Raghavendra Sharma
@Ankur I am assuming the integer to be 32 bits. actually it should be 0x step 1 : temp = (0x (32 - x)) n; step 2 : n = (n x) | ( temp (32 -x)); The first step extracts the lower x bits and second step moves upper bits to left side and puts the lower x bits at the