[algogeeks] Re: Check divisibility by 3

2009-08-19 Thread Dave
I think my solution, posted on August 16, but repeated here for ease of reference, is a more efficient... the body of the loop is simpler and the procedure does not use recursion. Given a value of n, for( i = iabs(n) + 3 ; i > 3 ; i = ( i & 3 ) + ( i >> 2 ) ); After the above loop, if i == 3, t

[algogeeks] Re: permuting the elements of an array

2009-08-19 Thread sandy
Please see http://geeksforgeeks.org/?p=767 for well explained C implementation of the same. On Jun 23, 10:01 am, Ajinkya Kale wrote: > Yeah c++ STL nextpermutation api will do it .. good solution Miroslav! > > On Tue, Jun 23, 2009 at 10:25 PM, Miroslav Balaz > wrote: > > > > > It is also so eas

[algogeeks] Re: Finding repeated element in most efficient way

2009-08-19 Thread fundoonick
I think your solution will work if the repeated number is a power of 2. The problem states that the repeated number is repeated 2, 4, 8, 16 times. for ex: consider 3,4,3 3 is repeated two times. your algo will return i when i=4 So i feel this is not the correct solution Rega

[algogeeks] Re: Check divisibility by 3

2009-08-19 Thread sandy
This is solved and very well explained at http://geeksforgeeks.org/?p=511 On Aug 17, 7:19 am, Abhijeet Kumar wrote: > i think the code given above doesn't work .. > so may be dat needs to be checked > any better ideas?? > > > > On Mon, Aug 17, 2009 at 7:20 PM, manish bhatia wrote: > > Keep

[algogeeks] Re: Looking for a suffix tree implementation with Unicode support

2009-08-19 Thread Arun N
I also have done suffix array its simple and fast Arun, On Wed, Aug 19, 2009 at 1:37 AM, Miroslav Balaz wrote: > What you mean by unicode supprot? > I think only problem is that characters that look the same may have > different encodings. > So it is enough in each compare to use the function tha

[algogeeks] Checking xml-file against a set of rules (when schema seems to be not enough)

2009-08-19 Thread Comanche
In brief: I'm looking for the best way to check that elements (in a xml file) go in proper order and are present at expected positions and with expected attribute "name", and if not - to understand which elements are missing (or are excessive or are at wrong position or have wrong attribute value)