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

2009-08-09 Thread ankur aggarwal
@ Anshya Aggarwal how xoring will help plz explain .. --~--~-~--~~~---~--~~ 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

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

2009-08-09 Thread Anshya Aggarwal
xoring will work On Sun, Aug 9, 2009 at 5:59 PM, Vikram Sridar wrote: > Sorting will tkae atleast a nlog(n)... this could be done in 0(n) if we > hash.. worst case that is > > > > > -- Anshya Aggarwal Sent from Delhi, DL, India --~--~-~--~~~---~--~~ You receive

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

2009-08-09 Thread Siddharth S
sorry, i thought the element that is repeated is of the form 2^i. :D On Sun, Aug 9, 2009 at 6:14 PM, Siddharth S wrote: > assuming the numbers are n-bit numbers, > 1. have an array, "arr", of n elements, initialize all elements with 0. > 2. traverse the "input" array > 3. if input[i] is a power

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

2009-08-09 Thread Siddharth S
assuming the numbers are n-bit numbers, 1. have an array, "arr", of n elements, initialize all elements with 0. 2. traverse the "input" array 3. if input[i] is a power of 2, arr[ lg(input[i]) ] ++; // where lg is logarithm to the base 2. 4. after traversing input array, see if any element i

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

2009-08-09 Thread Vikram Sridar
Sorting will tkae atleast a nlog(n)... this could be done in 0(n) if we hash.. worst case that is --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks

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

2009-08-09 Thread ankur aggarwal
@richa.. ques is in complete i think . there shud be some conditions given .. otherwise hash them but lots of space will b wasted.. or sort them try to put the conditions.. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

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

2009-08-09 Thread santhosh venkat
http://en.wikipedia.org/wiki/Pigeonhole_sortI think it was the repliers intention. But i think it is not the most optimal way of solving the question as the amount of memory it needs in the worst case is higher On Sun, Aug 9, 2009 at 1:47 PM, richa gup

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

2009-08-09 Thread richa gupta
what is this pigeonhole sort ?? 2009/8/9 sharad kumar > use pigeonhole sort > > > On Sun, Aug 9, 2009 at 12:47 PM, richa gupta wrote: > >> Hi, >> An array consists of all unique integers but one. The repeated element >> repeats in the order of two i.e. the repeated integer is 2, 4, 8, 16, >> etc

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

2009-08-09 Thread sharad kumar
use pigeonhole sort On Sun, Aug 9, 2009 at 12:47 PM, richa gupta wrote: > Hi, > An array consists of all unique integers but one. The repeated element > repeats in the order of two i.e. the repeated integer is 2, 4, 8, 16, > etc times in the array. > How to find the repeated element in most effi

[algogeeks] Finding repeated element in most efficient way

2009-08-09 Thread richa gupta
Hi, An array consists of all unique integers but one. The repeated element repeats in the order of two i.e. the repeated integer is 2, 4, 8, 16, etc times in the array. How to find the repeated element in most efficient way? -- Richa Gupta (IT-BHU,India) --~--~-~--~~~